a.binder 9 лет назад
Родитель
Сommit
7833347ee3
1 измененных файлов с 106 добавлено и 32 удалено
  1. 106 32
      SE/schema/default_db_xml_cache.public/builds_to_ant.xsl

+ 106 - 32
SE/schema/default_db_xml_cache.public/builds_to_ant.xsl

@@ -14,6 +14,16 @@
     <!--<xsl:param name="loop_xpath" required="yes"/>-->
     <xsl:param name="loop_xpath_real" required="yes"/>
     
+    <xsl:template name="last_slash">
+        <xsl:param name="string" required="yes"/>
+        <xsl:for-each select="tokenize($string,'/')">
+            <xsl:if test="position()= last()">
+                <xsl:value-of select="."/>
+            </xsl:if>
+        </xsl:for-each>
+    </xsl:template>
+    
+    
     <xsl:template match="builds_to_ant">
         <project xmlns:gml="http://www.opengis.net/gml"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -25,22 +35,57 @@
             basedir="../."
             name="builds_to_ant_proj{$loop_xpath_real}"
             default="builds_to_ant{$loop_xpath_real}">
-            <target name="builds_to_ant{$loop_xpath_real}">
+            <xsl:element name="target">
+                <xsl:attribute name="name" select="concat('builds_to_ant',$loop_xpath_real)"/>
+                <xsl:variable name="last_slash">
+                    <xsl:call-template name="last_slash">
+                        <xsl:with-param name="string" select="$temp"/>
+                    </xsl:call-template>
+                </xsl:variable>
                 <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
-                
-            <xsl:for-each select="tokenize(.,';')">
-                <echo>
-                    #
-                    #    
-                    #
-                    #
-                        builds_to_ant - za chwile uruchomie antfile  temp/<xsl:value-of select="."/>;
-                    #
-                    #
-                </echo>
-                <ant antfile="{$temp}/{.}" dir="."/>
-            </xsl:for-each>
-            </target>
+                <xsl:choose>
+                    <xsl:when test="1=2"> <!-- $last_slash='temp' -->
+                        <xsl:message> FIRST LEVEL ANT is executed in PARALLEL </xsl:message>
+                        <echo>
+                            #
+                            #    
+                            builds_to_ant - uruchomienie ANT w parallel  temp/<xsl:value-of select="."/>;
+                            #
+                            #
+                        </echo>
+                        <parallel>
+                            <xsl:for-each select="tokenize(.,';')">
+                                <java>
+                                    <xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>
+                                    <xsl:attribute name="dir" select="'${basedir}'"/>
+                                    <xsl:attribute name="fork" select="'true'"/>
+                                    <xsl:attribute name="clonevm" select="'true'"/>
+                                    <xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>
+                                    <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
+                                    <arg value="-buildfile"/>
+                                    <arg value="{$temp}/{.}"/>
+                                </java>
+                            </xsl:for-each>
+                        </parallel>
+                        
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:message> SECOND AND NEXT LEVEL ANT is executed in normal </xsl:message>
+                        <xsl:for-each select="tokenize(.,';')">
+                            <echo>
+                                #
+                                #    
+                                #
+                                #
+                                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="."/>;
+                                #
+                                #
+                            </echo>
+                            <ant antfile="{$temp}/{.}" dir="."/>
+                        </xsl:for-each>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:element>
         </project>
     </xsl:template>
     
@@ -58,23 +103,52 @@
             default="builds_to_ant{$loop_xpath_real}">
             <target name="builds_to_ant{$loop_xpath_real}">
                 <xsl:comment> default_antfile: <xsl:value-of select="$default_antfile"/> ; </xsl:comment>
-                
-                <xsl:for-each select="tokenize(.,';')">
-                    <echo>
-                        #
-                        #    
-                        #
-                        #
-                        builds_to_ant - za chwile uruchomie antfile  exec temp/<xsl:value-of select="."/>;
-                        #
-                        #
-                    </echo>
-                    <exec command="/opt/local/bin/ant" dir="{$temp}" failifexecutionfails="true">
-                        <xsl:element name="arg">
-                            <xsl:attribute name="line" select="concat('-f ',.,'/build_root.xml')"/>
-                        </xsl:element>
-                    </exec>
-                </xsl:for-each>
+                <!-- robimy na paraler  -->
+                <xsl:choose>
+                    <xsl:when test="1=2">
+                        <echo>
+                            #
+                            #    
+                            #
+                            #
+                            builds_to_ant - PARALLEL RUN  za chwile uruchomie antfile  LOOP exec <xsl:value-of select="."/>/build_root.xml ;
+                            #
+                            #
+                        </echo>
+                        <parallel>
+                            <xsl:for-each select="tokenize(.,';')">
+                                <java>
+                                    <xsl:attribute name="classname" select="'org.apache.tools.ant.Main'"/>
+                                    <xsl:attribute name="dir" select="concat($temp,'/',.)"/>
+                                    <xsl:attribute name="fork" select="'false'"/>
+                                    <xsl:attribute name="clonevm" select="'false'"/>
+                                    <xsl:attribute name="resultproperty" select="concat(.,'_resprop')"/>
+                                    <!--<xsl:attribute name="output" select="concat(.,'_out.log')"/>-->
+                                    <arg value="-buildfile"/>
+                                    <arg value="build_root.xml"/>
+                                </java>
+                            </xsl:for-each>
+                        </parallel>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:for-each select="tokenize(.,';')">
+                            <echo>
+                                #
+                                #    
+                                #
+                                #
+                                builds_to_ant - za chwile uruchomie antfile  LOOP exec temp/<xsl:value-of select="."/>;
+                                #
+                                #
+                            </echo>
+                            <exec executable="/opt/local/bin/ant" dir="{$temp}" failifexecutionfails="true">
+                                <xsl:element name="arg">
+                                    <xsl:attribute name="line" select="concat('-f ',.,'/build_root.xml')"/>
+                                </xsl:element>
+                            </exec>
+                        </xsl:for-each>
+                    </xsl:otherwise>
+                </xsl:choose>
             </target>
         </project>
     </xsl:template>