builds_to_ant.xsl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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:template name="last_slash">
  14. <xsl:param name="string" required="yes"/>
  15. <xsl:for-each select="tokenize($string,'/')">
  16. <xsl:if test="position()= last()">
  17. <xsl:value-of select="."/>
  18. </xsl:if>
  19. </xsl:for-each>
  20. </xsl:template>
  21. <xsl:template match="builds_to_ant">
  22. <project xmlns:gml="http://www.opengis.net/gml"
  23. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24. xmlns:xlink="http://www.w3.org/1999/xlink"
  25. xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db"
  26. xmlns:wfs="http://www.opengis.net/wfs"
  27. xmlns:ogc="http://www.opengis.net/ogc"
  28. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  29. basedir="../."
  30. name="builds_to_ant_proj{$loop_xpath_real}"
  31. default="builds_to_ant{$loop_xpath_real}">
  32. <xsl:element name="target">
  33. <xsl:attribute name="name" select="concat('builds_to_ant',$loop_xpath_real)"/>
  34. <xsl:variable name="last_slash">
  35. <xsl:call-template name="last_slash">
  36. <xsl:with-param name="string" select="$temp"/>
  37. </xsl:call-template>
  38. </xsl:variable>
  39. <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
  40. <xsl:choose>
  41. <xsl:when test="1=1"> <!-- $last_slash='temp' -->
  42. <xsl:message> FIRST LEVEL ANT is executed in PARALLEL </xsl:message>
  43. <echo>
  44. #
  45. #
  46. builds_to_ant - uruchomienie ANT w parallel temp/<xsl:value-of select="."/>;
  47. #
  48. #
  49. </echo>
  50. <parallel>
  51. <xsl:for-each select="tokenize(.,';')">
  52. <java>
  53. <xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>
  54. <xsl:attribute name="dir" select="'${basedir}'"/>
  55. <xsl:attribute name="fork" select="'true'"/>
  56. <xsl:attribute name="clonevm" select="'true'"/>
  57. <!--<xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>-->
  58. <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
  59. <arg value="-buildfile"/>
  60. <arg value="{$temp}/{.}"/>
  61. </java>
  62. </xsl:for-each>
  63. </parallel>
  64. </xsl:when>
  65. <xsl:otherwise>
  66. <xsl:message> SECOND AND NEXT LEVEL ANT is executed in normal </xsl:message>
  67. <xsl:for-each select="tokenize(.,';')">
  68. <echo>
  69. #
  70. #
  71. #
  72. #
  73. 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="."/>;
  74. #
  75. #
  76. </echo>
  77. <ant antfile="{$temp}/{.}" dir="."/>
  78. </xsl:for-each>
  79. </xsl:otherwise>
  80. </xsl:choose>
  81. </xsl:element>
  82. </project>
  83. </xsl:template>
  84. <xsl:template match="builds_to_ant" mode="exec">
  85. <project xmlns:gml="http://www.opengis.net/gml"
  86. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  87. xmlns:xlink="http://www.w3.org/1999/xlink"
  88. xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db"
  89. xmlns:wfs="http://www.opengis.net/wfs"
  90. xmlns:ogc="http://www.opengis.net/ogc"
  91. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  92. basedir="../."
  93. name="builds_to_ant_proj{$loop_xpath_real}"
  94. default="builds_to_ant{$loop_xpath_real}">
  95. <target name="builds_to_ant{$loop_xpath_real}">
  96. <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
  97. <!-- robimy na paraler -->
  98. <xsl:choose>
  99. <xsl:when test="1=2">
  100. <echo>
  101. #
  102. #
  103. #
  104. #
  105. builds_to_ant - PARALLEL RUN za chwile uruchomie antfile LOOP exec <xsl:value-of select="."/>/build_root.xml ;
  106. #
  107. #
  108. </echo>
  109. <parallel>
  110. <xsl:for-each select="tokenize(.,';')">
  111. <java>
  112. <xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>
  113. <xsl:attribute name="dir" select="concat($temp,'/',.)"/>
  114. <xsl:attribute name="fork" select="'false'"/>
  115. <xsl:attribute name="clonevm" select="'false'"/>
  116. <xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>
  117. <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
  118. <arg value="-buildfile"/>
  119. <arg value="build_root.xml"/>
  120. </java>
  121. </xsl:for-each>
  122. </parallel>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:for-each select="tokenize(.,';')">
  126. <echo>
  127. #
  128. #
  129. #
  130. #
  131. builds_to_ant - za chwile uruchomie antfile LOOP exec temp/<xsl:value-of select="."/>;
  132. #
  133. #
  134. </echo>
  135. <exec executable="/opt/local/bin/ant" dir="{$temp}" failifexecutionfails="true">
  136. <xsl:element name="arg">
  137. <xsl:attribute name="line" select="concat('-f ',.,'/build_root.xml')"/>
  138. </xsl:element>
  139. </exec>
  140. </xsl:for-each>
  141. </xsl:otherwise>
  142. </xsl:choose>
  143. </target>
  144. </project>
  145. </xsl:template>
  146. </xsl:stylesheet>