builds_to_ant.xsl 11 KB

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