builds_to_ant.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. exclude-result-prefixes="xs"
  5. version="2.0">
  6. <!-- template do zbudowania listy podzadan na podsatwie <fileset id="builds_to_ant" dir="temp" includes="prezes1.build_root_x2f_.d1e1.CRM_PROCES_x2f_.d1e46.CRM_WSKAZNIK_x2f_.d1e51.CRM_LISTA_ZASOBOW.*" /> -->
  7. <xsl:output indent="yes"/>
  8. <xsl:strip-space elements="*"/>
  9. <xsl:param name="temp" required="yes"/>
  10. <xsl:param name="default_antfile"/>
  11. <!--<xsl:param name="loop_xpath" required="yes"/>-->
  12. <xsl:param name="loop_xpath_real" required="yes"/>
  13. <xsl:param name="xpath_query" required="yes"/>
  14. <xsl:param name="featureID_name_dita" required="yes"/>
  15. <xsl:param name="xpath_query_test.xml"/>
  16. <!--<xsl:param name="recurse_ant_basedir" required="yes"/>-->
  17. <!--<xsl:param name="temp_current" required="yes"/>-->
  18. <xsl:param name="ant-launcher.jar"/>
  19. <xsl:variable name="xpath_query_test">
  20. <xsl:choose>
  21. <xsl:when test="$xpath_query_test.xml">
  22. <xsl:copy-of select="doc($xpath_query_test.xml)"/>
  23. </xsl:when>
  24. <xsl:otherwise>
  25. <xpath_query_test>OK</xpath_query_test>
  26. </xsl:otherwise>
  27. </xsl:choose>
  28. </xsl:variable>
  29. <xsl:template name="last_slash">
  30. <xsl:param name="string" required="yes"/>
  31. <xsl:for-each select="tokenize($string,'/')">
  32. <xsl:if test="position()= last()">
  33. <xsl:value-of select="."/>
  34. </xsl:if>
  35. </xsl:for-each>
  36. </xsl:template>
  37. <xsl:template match="builds_to_ant">
  38. <project xmlns:gml="http://www.opengis.net/gml"
  39. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40. xmlns:xlink="http://www.w3.org/1999/xlink"
  41. xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db"
  42. xmlns:wfs="http://www.opengis.net/wfs"
  43. xmlns:ogc="http://www.opengis.net/ogc"
  44. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  45. basedir="../."
  46. name="builds_to_ant_proj{$loop_xpath_real}"
  47. default="builds_to_ant{$loop_xpath_real}">
  48. <xsl:element name="target">
  49. <xsl:attribute name="name" select="concat('builds_to_ant',$loop_xpath_real)"/>
  50. <xsl:variable name="last_slash">
  51. <xsl:call-template name="last_slash">
  52. <xsl:with-param name="string" select="$temp"/>
  53. </xsl:call-template>
  54. </xsl:variable>
  55. <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
  56. <xsl:choose>
  57. <xsl:when test="not($xpath_query_test/xpath_query_test='OK')">
  58. <xsl:message> $xpath_query_test NOT OK - bypassed by xpath_query filter </xsl:message>
  59. <echo> $xpath_query_test NOT OK - bypassed by xpath_query filter </echo>
  60. </xsl:when>
  61. <xsl:when test="1=2"> <!-- $last_slash='temp' -->
  62. <xsl:message> FIRST LEVEL ANT is executed in PARALLEL </xsl:message>
  63. <echo>
  64. #
  65. #
  66. builds_to_ant - uruchomienie ANT w parallel temp/<xsl:value-of select="."/>;
  67. $xpath_query=<xsl:value-of select="$xpath_query"/>;
  68. $xpath_query_test/xpath_query_test=<xsl:value-of select="$xpath_query_test/xpath_query_test"/>;
  69. $featureID_name_dita<xsl:value-of select="$featureID_name_dita"/>;
  70. #
  71. #
  72. </echo>
  73. <parallel threadCount="4" failonany="true"> <!-- threadCount="4" -->
  74. <xsl:for-each select="tokenize(.,';')">
  75. <java>
  76. <xsl:attribute name="jar" select="$ant-launcher.jar"/>
  77. <!--<xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>-->
  78. <!--<xsl:attribute name="dir" select="'${basedir}'"/>-->
  79. <xsl:attribute name="fork" select="'true'"/>
  80. <xsl:attribute name="clonevm" select="'true'"/>
  81. <xsl:attribute name="failonerror" select="'true'"/>
  82. <!--<xsl:attribute name="append" select="'false'"/>-->
  83. <xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>
  84. <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
  85. <arg value="-buildfile"/>
  86. <arg value="{$temp}/{.}"/>
  87. </java>
  88. </xsl:for-each>
  89. </parallel>
  90. <echo>#
  91. #
  92. #
  93. #
  94. #94 i run all PARALLEL TASKS - should wait some time!
  95. #
  96. #
  97. #
  98. #</echo>
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <xsl:message> SECOND AND NEXT LEVEL ANT is executed in normal </xsl:message>
  102. <xsl:for-each select="tokenize(.,';')">
  103. <echo>
  104. #
  105. #
  106. #
  107. #
  108. builds_to_ant - za chwile uruchomie antfile (NOT PARALLEL) $last_slash=<xsl:value-of select="$last_slash"/>; $loop_xpath_real=<xsl:value-of select="$loop_xpath_real"/>; temp/<xsl:value-of select="."/>;
  109. $xpath_query=<xsl:value-of select="$xpath_query"/>;
  110. $featureID_name_dita<xsl:value-of select="$featureID_name_dita"/>;
  111. #
  112. #
  113. </echo>
  114. <ant antfile="{$temp}/{.}" dir="."/>
  115. </xsl:for-each>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:element>
  119. </project>
  120. </xsl:template>
  121. <xsl:template match="builds_to_ant" mode="exec">
  122. <project xmlns:gml="http://www.opengis.net/gml"
  123. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  124. xmlns:xlink="http://www.w3.org/1999/xlink"
  125. xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db"
  126. xmlns:wfs="http://www.opengis.net/wfs"
  127. xmlns:ogc="http://www.opengis.net/ogc"
  128. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  129. basedir="../."
  130. name="builds_to_ant_proj{$loop_xpath_real}"
  131. default="builds_to_ant{$loop_xpath_real}">
  132. <target name="builds_to_ant{$loop_xpath_real}">
  133. <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
  134. <!-- robimy na paraler -->
  135. <xsl:choose>
  136. <xsl:when test="not($xpath_query_test/xpath_query_test='OK')">
  137. <xsl:message> $xpath_query_test NOT OK - bypassed by xpath_query filter </xsl:message>
  138. <echo> $xpath_query_test NOT OK - bypassed by xpath_query filter </echo>
  139. </xsl:when>
  140. <xsl:when test="1=2"> <!-- error brak klasy Error: Could not find or load main class org.apache.tools.ant.Main -->
  141. <echo>
  142. #
  143. #
  144. #
  145. #
  146. builds_to_ant - PARALLEL RUN za chwile uruchomie antfile LOOP exec <xsl:value-of select="concat($temp,'/',.)"/>/build_root.xml ;
  147. $xpath_query=<xsl:value-of select="$xpath_query"/>;
  148. $xpath_query_test/xpath_query_test=<xsl:value-of select="$xpath_query_test/xpath_query_test"/>;
  149. $featureID_name_dita<xsl:value-of select="$featureID_name_dita"/>;
  150. #
  151. #
  152. </echo>
  153. <parallel threadCount="4" failonany="true">
  154. <xsl:for-each select="tokenize(.,';')">
  155. <java>
  156. <xsl:attribute name="jar" select="$ant-launcher.jar"/>
  157. <!--<xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>-->
  158. <xsl:attribute name="dir" select="concat($temp,'/',.)"/>
  159. <xsl:attribute name="fork" select="'true'"/>
  160. <xsl:attribute name="clonevm" select="'false'"/>
  161. <xsl:attribute name="newenvironment" select="'true'"/>
  162. <xsl:attribute name="failonerror" select="'true'"/>
  163. <!--<xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>-->
  164. <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
  165. <arg value="-buildfile"/>
  166. <arg value="{$temp}/{.}/build_root.xml"/>
  167. </java>
  168. </xsl:for-each>
  169. </parallel>
  170. </xsl:when>
  171. <xsl:otherwise>
  172. <xsl:for-each select="tokenize(.,';')">
  173. <echo>
  174. #
  175. #
  176. #
  177. #
  178. builds_to_ant - za chwile uruchomie antfile LOOP exec temp/<xsl:value-of select="."/>;
  179. $xpath_query=<xsl:value-of select="$xpath_query"/>;
  180. $featureID_name_dita<xsl:value-of select="$featureID_name_dita"/>;
  181. #
  182. #
  183. </echo>
  184. <exec executable="/opt/local/bin/ant" dir="{$temp}" failifexecutionfails="true">
  185. <xsl:element name="arg">
  186. <xsl:attribute name="line" select="concat('-f ',$temp,'/',.,'/build_root.xml')"/>
  187. </xsl:element>
  188. </exec>
  189. <!--<ant antfile="{.}/build_root.xml" dir="{$temp}" inheritall="false" usenativebasedir="true" />-->
  190. </xsl:for-each>
  191. </xsl:otherwise>
  192. </xsl:choose>
  193. </target>
  194. </project>
  195. </xsl:template>
  196. </xsl:stylesheet>