builds_to_ant.xsl 11 KB

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