cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r123469 - /cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
Date Tue, 28 Dec 2004 04:33:38 GMT
Author: antonio
Date: Mon Dec 27 20:33:37 2004
New Revision: 123469

URL: http://svn.apache.org/viewcvs?view=rev&rev=123469
Log:
Use <macrodef>
Modified:
   cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl

Modified: cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl?view=diff&rev=123469&p1=cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl&r1=123468&p2=cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl&r2=123469
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl	(original)
+++ cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl	Mon Dec 27 20:33:37 2004
@@ -61,6 +61,351 @@
         <exclude name="**/package.html"/>
       </patternset>
 
+      <macrodef name="test-include-block">
+        <attribute name="name"/>
+        <sequential>
+           <condition property="include.block.@{{name}}">
+          <not>
+            <istrue value="${{exclude.block.@{{name}}}}"/>
+          </not>
+        </condition>
+        <condition property="internal.exclude.block.@{{name}}">
+          <isfalse value="${{include.block.@{{name}}}}"/>
+        </condition>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="print-excluded-block">
+        <attribute name="name"/>
+        <sequential>
+            <if>
+              <istrue value="${{internal.exclude.block.@{{name}}}}"/>
+              <then>
+                <echo message=" Block '@{{name}}' is excluded from the build."/>
+              </then>
+            </if>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-compile">
+        <attribute name="name"/>
+        <attribute name="package"/>
+        <sequential>
+        <!-- Test if this block has special build -->
+          <if>
+            <available file="${{blocks}}/@{{name}}/build.xml"/>
+            <then>
+              <ant inheritAll="true"
+                   inheritRefs="false"
+                   target="main"
+                   antfile="${{blocks}}/@{{name}}/build.xml">
+                <property name="block.dir" value="${{blocks}}/@{{name}}"/>
+              </ant>
+            </then>
+          </if>
+          <!-- Test if this block has mocks -->
+          <if>
+            <available type="dir" file="${{blocks}}/@{{name}}/mocks/"/>
+            <then>
+              <mkdir dir="${{build.blocks}}/@{{name}}/mocks"/>
+              <javac srcdir="${{blocks}}/@{{name}}/mocks"
+                     destdir="${{build.blocks}}/@{{name}}/mocks"
+                     debug="${{compiler.debug}}"
+                     optimize="${{compiler.optimize}}"
+                     deprecation="${{compiler.deprecation}}"
+                     target="${{target.vm}}"
+                     nowarn="${{compiler.nowarn}}"
+                     compiler="${{compiler}}">
+                <classpath refid="@{{name}}.classpath"/>
+              </javac>
+            </then>
+          </if>
+          <!-- This is a little bit tricky:
+           As the javac task checks, if a src directory is available and
+           stops if its not available, we use the following property
+           to either point to a jdk dependent directory or - if not
+           available - to the usual java source directory.
+           If someone knows a better solution...
+      -->
+      <!-- Currently, we have no JVM dependent sources
+      <condition property="dependend.vm" value="${{target.vm}}">
+        <available file="${{blocks}}/@{{name}}/java${{target.vm}}"/>
+      </condition>
+      <condition property="dependend.vm" value="">
+        <not>
+          <available file="${{blocks}}/@{{name}}/java${{target.vm}}"/>
+        </not>
+      </condition>
+      -->
+      <javac destdir="${{build.blocks}}/@{{name}}/dest"
+             debug="${{compiler.debug}}"
+             optimize="${{compiler.optimize}}"
+             deprecation="${{compiler.deprecation}}"
+             target="${{target.vm}}"
+             nowarn="${{compiler.nowarn}}"
+             compiler="${{compiler}}">
+        <src path="${{blocks}}/@{{name}}/java"/>
+        <!-- Currently, we have no JVM dependent sources
+        <src path="${{blocks}}/@{{name}}/java${{dependend.vm}}"/>
+        -->
+        <classpath refid="@{{name}}.classpath"/>
+        <exclude name="**/samples/**/*.java"/>
+      </javac>
+
+      <copy filtering="on" todir="${{build.blocks}}/@{{name}}/dest">
+        <fileset dir="${{blocks}}/@{{name}}/java">
+          <patternset refid="unprocessed.sources"/>
+        </fileset>
+      </copy>
+
+      <copy filtering="off" todir="${{build.blocks}}/@{{name}}/dest">
+        <fileset dir="${{blocks}}/@{{name}}/java">
+          <include name="**/Manifest.mf"/>
+          <include name="META-INF/**"/>
+        </fileset>
+      </copy>
+      <jar jarfile="${{build.blocks}}/@{{name}}-block.jar" index="true">
+        <fileset dir="${{build.blocks}}/@{{name}}/dest">
+          <include name="@{{package}}/**"/>
+          <include name="META-INF/**"/>
+        </fileset>
+      </jar>
+            <if>
+        <istrue value="${{include.sources-in-jars}}"/>
+        <then>
+          <jar jarfile="${{build.blocks}}/@{{name}}-block.jar" update="true">
+            <fileset dir="${{blocks}}/@{{name}}/java">
+              <include name="**/*.java"/>
+            </fileset>
+          </jar>
+        </then>
+      </if>
+
+      <if>
+        <istrue value="${{include.sources-jars}}"/>
+        <then>
+          <jar jarfile="${{build.blocks}}/@{{name}}-block.src.jar">
+            <fileset dir="${{blocks}}/@{{name}}/java">
+              <include name="**/*.java"/>
+            </fileset>
+          </jar>
+        </then>
+      </if>
+
+      <!-- exclude sample classes from the block package -->
+      <if>
+        <isfalse value="${{internal.exclude.webapp.samples}}"/>
+        <then>
+          <mkdir dir="${{build.blocks}}/@{{name}}/samples"/>
+          <javac destdir="${{build.blocks}}/@{{name}}/samples"
+             debug="${{compiler.debug}}"
+             optimize="${{compiler.optimize}}"
+             deprecation="${{compiler.deprecation}}"
+             target="${{target.vm}}"
+             nowarn="${{compiler.nowarn}}"
+             compiler="${{compiler}}">
+            <src path="${{blocks}}/@{{name}}/java"/>
+            <!-- Currently, we have no JVM dependent sources
+            <src path="${{blocks}}/@{{name}}/java${{dependend.vm}}"/>
+            -->
+            <classpath refid="@{{name}}.classpath"/>
+            <include name="**/samples/**/*.java"/>
+          </javac>
+        </then>
+      </if>
+       </sequential>
+   </macrodef>
+
+   <macrodef name="block-patch">
+        <attribute name="name"/>
+        <sequential>
+          <xpatch file="${{build.webapp}}/sitemap.xmap" srcdir="${{blocks}}">
+            <include name="@{{name}}/conf/*.xmap"/>
+          </xpatch>
+          <xpatch file="${{build.webapp}}/WEB-INF/cocoon.xconf" srcdir="${{blocks}}" addcomments="true">
+            <include name="@{{name}}/conf/*.xconf"/>
+          </xpatch>
+          <xpatch file="${{build.webapp}}/WEB-INF/logkit.xconf" srcdir="${{blocks}}">
+            <include name="@{{name}}/conf/*.xlog"/>
+          </xpatch>
+          <xpatch file="${{build.webapp}}/WEB-INF/web.xml" srcdir="${{blocks}}">
+            <include name="@{{name}}/conf/*.xweb"/>
+          </xpatch>
+
+          <!-- generate sitemap entries
+          <sitemap-components sitemap="${{build.webapp}}/sitemap.xmap"
+                              source="${{blocks}}/@{{name}}/java"
+                              block="@{{name}}">
+            <xsl:if test="@status='unstable'">
+              <xsl:attribute name="stable">false</xsl:attribute>
+            </xsl:if>
+            <xsl:if test="@status='deprecated'">
+              <xsl:attribute name="deprecated">true</xsl:attribute>
+            </xsl:if>
+          </sitemap-components>
+          -->
+
+          <!-- generate sitemap components docs -->
+          <!-- TODO - this is the wrong place for documentation, but currently blocks
+               don't have own docs!
+            <mkdir dir="${{build.context}}/xdocs/userdocs"/>
+          <sitemap-components docDir="${{build.context}}/xdocs/userdocs"
+                              source="${{blocks}}/@{{name}}/java"
+                              block="@{{name}}">
+            <xsl:if test="@status='unstable'">
+              <xsl:attribute name="stable">false</xsl:attribute>
+            </xsl:if>
+            <xsl:if test="@status='deprecated'">
+              <xsl:attribute name="deprecated">true</xsl:attribute>
+            </xsl:if>
+          </sitemap-components>
+          -->
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-roles">
+        <attribute name="name"/>
+        <sequential>
+            <xpatch file="${{build.dest}}/org/apache/cocoon/cocoon.roles" srcdir="${{blocks}}">
+                <include name="@{{name}}/conf/*.xroles"/>
+            </xpatch>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-patch-samples">
+        <attribute name="name"/>
+        <sequential>
+            <xpatch file="${{build.webapp}}/samples/sitemap.xmap" srcdir="${{blocks}}">
+                <include name="@{{name}}/conf/*.samplesxpipe"/>
+            </xpatch>
+            <xpatch file="${{build.webapp}}/WEB-INF/cocoon.xconf" srcdir="${{blocks}}">
+                <include name="@{{name}}/conf/*.samplesxconf"/>
+            </xpatch>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-samples">
+        <attribute name="name"/>
+        <sequential>
+          <!-- Test if this block has samples -->
+          <if>
+            <available file="${{blocks}}/@{{name}}/samples/sitemap.xmap"/>
+            <then>
+              <copy filtering="on" todir="${{build.webapp}}/samples/blocks/@{{name}}">
+                <fileset dir="${{blocks}}/@{{name}}/samples"/>
+                <fileset dir="${{blocks}}/@{{name}}/conf" includes="*.xsamples"/>
+              </copy>
+              <!-- copy sample classes -->
+              <copy todir="${{build.webapp.classes}}" filtering="off">
+                <fileset dir="${{build.blocks}}/@{{name}}/samples"/>
+              </copy>
+            </then>
+          </if>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-lib">
+        <attribute name="name"/>
+        <sequential>
+          <!-- if this block has a lib directory copy those too (deprecated) -->
+          <if>
+            <available type="dir" file="${{blocks}}/@{{name}}/lib"/>
+            <then>
+              <echo>
+              NOTICE: the preferred method of including library dependencies in your block
+              is by putting them in lib/optional and then declaring them in gump.xml.
+              </echo>
+              <copy filtering="off" todir="${{build.webapp.lib}}">
+                <fileset dir="${{blocks}}/@{{name}}/lib">
+                  <include name="*.jar"/>
+                  <exclude name="servlet*.jar"/>
+                </fileset>
+              </copy>
+            </then>
+          </if>
+          <!-- Test if this block has global WEB-INF files -->
+          <if>
+            <available type="dir" file="${{blocks}}/@{{name}}/WEB-INF/"/>
+            <then>
+              <copy filtering="on" todir="${{build.webapp.webinf}}">
+                <fileset dir="${{blocks}}/@{{name}}/WEB-INF/">
+                  <include name="**"/>
+                </fileset>
+              </copy>
+            </then>
+          </if>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-tests">
+        <attribute name="name"/>
+        <sequential>
+          <!-- Test if this block has tests -->
+          <if>
+            <available file="${{blocks}}/@{{name}}/test"/>
+            <then>
+              <mkdir dir="${{build.blocks}}/@{{name}}/test"/>
+
+              <copy todir="${{build.blocks}}/@{{name}}/test" filtering="on">
+                <fileset dir="${{blocks}}/@{{name}}/test" excludes="**/*.java"/>
+              </copy>
+
+              <javac destdir="${{build.blocks}}/@{{name}}/test"
+                     debug="${{compiler.debug}}"
+                     optimize="${{compiler.optimize}}"
+                     deprecation="${{compiler.deprecation}}"
+                     target="${{target.vm}}"
+                     nowarn="${{compiler.nowarn}}"
+                     compiler="${{compiler}}">
+                <src path="${{blocks}}/@{{name}}/test"/>
+                <classpath>
+                  <path refid="@{{name}}.classpath"/>
+                  <path refid="test.classpath"/>
+                  <pathelement location="${{build.test}}"/>
+                </classpath>
+              </javac>
+
+              <junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
+                <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
+                <jvmarg value="-Djunit.test.loglevel=${{junit.test.loglevel}}"/>
+                <classpath>
+                  <path refid="@{{name}}.classpath"/>
+                  <path refid="test.classpath"/>
+                  <pathelement location="${{build.test}}"/>
+                  <pathelement location="${{build.blocks}}/@{{name}}/test"/>
+                </classpath>
+                <formatter type="plain" usefile="no"/>
+                <formatter type="xml"/>
+                <batchtest todir="${{build.test.output}}">
+                  <fileset dir="${{build.blocks}}/@{{name}}/test">
+                    <include name="**/*TestCase.class"/>
+                    <include name="**/*Test.class"/>
+                    <exclude name="**/AllTest.class"/>
+                    <exclude name="**/*$$*Test.class"/>
+                    <exclude name="**/Abstract*.class"/>
+                  </fileset>
+                </batchtest>
+              </junit>
+            </then>
+          </if>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="block-prepare-anteater-tests">
+        <attribute name="name"/>
+        <sequential>
+          <!-- Test if this block has Anteater tests -->
+          <if>
+            <available file="${{blocks}}/@{{name}}/test/anteater"/>
+            <then>
+              <copy todir="${{build.test}}/anteater">
+                <fileset dir="${{blocks}}/@{{name}}/test/anteater"/>
+                <mapper type="glob" from="*.xml" to="@{{name}}-*.xml"/>
+              </copy>
+            </then>
+          </if>
+        </sequential>
+    </macrodef>
       <xsl:apply-templates select="module"/>
     </project>
   </xsl:template>
@@ -71,14 +416,7 @@
     <target name="init">
       <xsl:for-each select="$cocoon-blocks">
         <xsl:variable name="block-name" select="substring-after(@name,'cocoon-block-')"/>
-        <condition property="include.block.{$block-name}">
-          <not>
-            <istrue value="${{exclude.block.{$block-name}}}"/>
-          </not>
-        </condition>
-        <condition property="internal.exclude.block.{$block-name}">
-          <isfalse value="${{include.block.{$block-name}}}"/>
-        </condition>
+        <test-include-block name="{$block-name}"/>
       </xsl:for-each>
     </target>
 
@@ -124,12 +462,7 @@
           <xsl:for-each select="$cocoon-blocks">
             <xsl:sort select="@name"/>
             <xsl:variable name="block-name" select="substring-after(@name,'cocoon-block-')"/>
-            <if>
-              <istrue value="${{internal.exclude.block.{$block-name}}}"/>
-              <then>
-                <echo message=" Block '{$block-name}' is excluded from the build."/>
-              </then>
-            </if>
+                <print-excluded-block name="{$block-name}"/>
           </xsl:for-each>
           <echo message="===================================================="/>
         </then>
@@ -349,133 +682,7 @@
           </xsl:for-each>
         </xsl:if>
       </xsl:attribute>
-
-      <!-- Test if this block has special build -->
-      <if>
-        <available file="${{blocks}}/{$block-name}/build.xml"/>
-        <then>
-          <ant inheritAll="true"
-               inheritRefs="false"
-               target="main"
-               antfile="${{blocks}}/{$block-name}/build.xml">
-            <property name="block.dir" value="${{blocks}}/{$block-name}"/>
-          </ant>
-        </then>
-      </if>
-
-      <!-- Test if this block has mocks -->
-      <if>
-        <available type="dir" file="${{blocks}}/{$block-name}/mocks/"/>
-        <then>
-          <mkdir dir="${{build.blocks}}/{$block-name}/mocks"/>
-          <javac srcdir="${{blocks}}/{$block-name}/mocks"
-                 destdir="${{build.blocks}}/{$block-name}/mocks"
-                 debug="${{compiler.debug}}"
-                 optimize="${{compiler.optimize}}"
-                 deprecation="${{compiler.deprecation}}"
-                 target="${{target.vm}}"
-                 nowarn="${{compiler.nowarn}}"
-                 compiler="${{compiler}}">
-            <classpath refid="{$block-name}.classpath"/>
-          </javac>
-        </then>
-      </if>
-
-      <!-- This is a little bit tricky:
-           As the javac task checks, if a src directory is available and
-           stops if its not available, we use the following property
-           to either point to a jdk dependent directory or - if not
-           available - to the usual java source directory.
-           If someone knows a better solution...
-      -->
-      <!-- Currently, we have no JVM dependent sources
-      <condition property="dependend.vm" value="${{target.vm}}">
-        <available file="${{blocks}}/{$block-name}/java${{target.vm}}"/>
-      </condition>
-      <condition property="dependend.vm" value="">
-        <not>
-          <available file="${{blocks}}/{$block-name}/java${{target.vm}}"/>
-        </not>
-      </condition>
-      -->
-      <javac destdir="${{build.blocks}}/{$block-name}/dest"
-             debug="${{compiler.debug}}"
-             optimize="${{compiler.optimize}}"
-             deprecation="${{compiler.deprecation}}"
-             target="${{target.vm}}"
-             nowarn="${{compiler.nowarn}}"
-             compiler="${{compiler}}">
-        <src path="${{blocks}}/{$block-name}/java"/>
-        <!-- Currently, we have no JVM dependent sources
-        <src path="${{blocks}}/{$block-name}/java${{dependend.vm}}"/>
-        -->
-        <classpath refid="{$block-name}.classpath"/>
-        <exclude name="**/samples/**/*.java"/>
-      </javac>
-
-      <copy filtering="on" todir="${{build.blocks}}/{$block-name}/dest">
-        <fileset dir="${{blocks}}/{$block-name}/java">
-          <patternset refid="unprocessed.sources"/>
-        </fileset>
-      </copy>
-
-      <copy filtering="off" todir="${{build.blocks}}/{$block-name}/dest">
-        <fileset dir="${{blocks}}/{$block-name}/java">
-          <include name="**/Manifest.mf"/>
-          <include name="META-INF/**"/>
-        </fileset>
-      </copy>
-
-      <jar jarfile="${{build.blocks}}/{$block-name}-block.jar" index="true">
-        <fileset dir="${{build.blocks}}/{$block-name}/dest">
-          <include name="{translate(package/text(), '.', '/')}/**"/>
-          <include name="META-INF/**"/>
-        </fileset>
-      </jar>
-
-      <if>
-        <istrue value="${{include.sources-in-jars}}"/>
-        <then>
-          <jar jarfile="${{build.blocks}}/{$block-name}-block.jar" update="true">
-            <fileset dir="${{blocks}}/{$block-name}/java">
-              <include name="**/*.java"/>
-            </fileset>
-          </jar>
-        </then>
-      </if>
-
-      <if>
-        <istrue value="${{include.sources-jars}}"/>
-        <then>
-          <jar jarfile="${{build.blocks}}/{$block-name}-block.src.jar">
-            <fileset dir="${{blocks}}/{$block-name}/java">
-              <include name="**/*.java"/>
-            </fileset>
-          </jar>
-        </then>
-      </if>
-
-      <!-- exclude sample classes from the block package -->
-      <if>
-        <isfalse value="${{internal.exclude.webapp.samples}}"/>
-        <then>
-          <mkdir dir="${{build.blocks}}/{$block-name}/samples"/>
-          <javac destdir="${{build.blocks}}/{$block-name}/samples"
-             debug="${{compiler.debug}}"
-             optimize="${{compiler.optimize}}"
-             deprecation="${{compiler.deprecation}}"
-             target="${{target.vm}}"
-             nowarn="${{compiler.nowarn}}"
-             compiler="${{compiler}}">
-            <src path="${{blocks}}/{$block-name}/java"/>
-            <!-- Currently, we have no JVM dependent sources
-            <src path="${{blocks}}/{$block-name}/java${{dependend.vm}}"/>
-            -->
-            <classpath refid="{$block-name}.classpath"/>
-            <include name="**/samples/**/*.java"/>
-          </javac>
-        </then>
-      </if>
+      <block-compile name="{$block-name}" package="{translate(package/text(), '.', '/')}"/>
     </target>
 
     <target name="{@name}-patch" unless="internal.exclude.block.{$block-name}">
@@ -490,48 +697,7 @@
           </xsl:for-each>
         </xsl:if>
       </xsl:attribute>
-
-      <xpatch file="${{build.webapp}}/sitemap.xmap" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.xmap"/>
-      </xpatch>
-      <xpatch file="${{build.webapp}}/WEB-INF/cocoon.xconf" srcdir="${{blocks}}" addcomments="true">
-        <include name="{$block-name}/conf/*.xconf"/>
-      </xpatch>
-      <xpatch file="${{build.webapp}}/WEB-INF/logkit.xconf" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.xlog"/>
-      </xpatch>
-      <xpatch file="${{build.webapp}}/WEB-INF/web.xml" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.xweb"/>
-      </xpatch>
-
-      <!-- generate sitemap entries
-      <sitemap-components sitemap="${{build.webapp}}/sitemap.xmap"
-                          source="${{blocks}}/{$block-name}/java"
-                          block="{$block-name}">
-        <xsl:if test="@status='unstable'">
-          <xsl:attribute name="stable">false</xsl:attribute>
-        </xsl:if>
-        <xsl:if test="@status='deprecated'">
-          <xsl:attribute name="deprecated">true</xsl:attribute>
-        </xsl:if>
-      </sitemap-components>
-      -->
-
-      <!-- generate sitemap components docs -->
-      <!-- TODO - this is the wrong place for documentation, but currently blocks
-           don't have own docs!
-        <mkdir dir="${{build.context}}/xdocs/userdocs"/>
-      <sitemap-components docDir="${{build.context}}/xdocs/userdocs"
-                          source="${{blocks}}/{$block-name}/java"
-                          block="{$block-name}">
-        <xsl:if test="@status='unstable'">
-          <xsl:attribute name="stable">false</xsl:attribute>
-        </xsl:if>
-        <xsl:if test="@status='deprecated'">
-          <xsl:attribute name="deprecated">true</xsl:attribute>
-        </xsl:if>
-      </sitemap-components>
-      -->
+      <block-patch name="{$block-name}"/>
     </target>
 
     <target name="{@name}-roles" unless="internal.exclude.block.{$block-name}">
@@ -544,19 +710,11 @@
           </xsl:for-each>
         </xsl:attribute>
       </xsl:if>
-
-      <xpatch file="${{build.dest}}/org/apache/cocoon/cocoon.roles" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.xroles"/>
-      </xpatch>
+      <block-roles name="{$block-name}"/>
     </target>
 
     <target name="{@name}-patch-samples" unless="internal.exclude.block.{$block-name}">
-      <xpatch file="${{build.webapp}}/samples/sitemap.xmap" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.samplesxpipe"/>
-      </xpatch>
-      <xpatch file="${{build.webapp}}/WEB-INF/cocoon.xconf" srcdir="${{blocks}}">
-        <include name="{$block-name}/conf/*.samplesxconf"/>
-      </xpatch>
+        <block-patch-samples name="{$block-name}"/>
     </target>
 
     <target name="{@name}-samples" unless="internal.exclude.block.{$block-name}">
@@ -569,22 +727,7 @@
           </xsl:for-each>
         </xsl:attribute>
       </xsl:if>
-
-      <!-- Test if this block has samples -->
-      <if>
-        <available file="${{blocks}}/{$block-name}/samples/sitemap.xmap"/>
-        <then>
-          <copy filtering="on" todir="${{build.webapp}}/samples/blocks/{$block-name}">
-            <fileset dir="${{blocks}}/{$block-name}/samples"/>
-            <fileset dir="${{blocks}}/{$block-name}/conf" includes="*.xsamples"/>
-          </copy>
-
-          <!-- copy sample classes -->
-          <copy todir="${{build.webapp.classes}}" filtering="off">
-            <fileset dir="${{build.blocks}}/{$block-name}/samples"/>
-          </copy>
-        </then>
-      </if>
+      <block-samples name="{$block-name}"/>
     </target>
 
     <target name="{@name}-lib" unless="internal.exclude.block.{$block-name}">
@@ -608,38 +751,9 @@
           </fileset>
         </copy>
       </xsl:if>
-
-      <!-- if this block has a lib directory copy those too (deprecated) -->
-      <if>
-        <available type="dir" file="${{blocks}}/{$block-name}/lib"/>
-        <then>
-          <echo>
-          NOTICE: the preferred method of including library dependencies in your block
-          is by putting them in lib/optional and then declaring them in gump.xml.
-          </echo>
-          <copy filtering="off" todir="${{build.webapp.lib}}">
-            <fileset dir="${{blocks}}/{$block-name}/lib">
-              <include name="*.jar"/>
-              <exclude name="servlet*.jar"/>
-            </fileset>
-          </copy>
-        </then>
-      </if>
-
-      <!-- Test if this block has global WEB-INF files -->
-      <if>
-        <available type="dir" file="${{blocks}}/{$block-name}/WEB-INF/"/>
-        <then>
-          <copy filtering="on" todir="${{build.webapp.webinf}}">
-            <fileset dir="${{blocks}}/{$block-name}/WEB-INF/">
-              <include name="**"/>
-            </fileset>
-          </copy>
-        </then>
-      </if>
+      <block-lib name="{$block-name}"/>
     </target>
 
-
     <target name="{@name}-prepare" unless="internal.exclude.block.{$block-name}">
       <xsl:if test="depend">
         <xsl:attribute name="depends">
@@ -687,68 +801,11 @@
           </xsl:for-each>
         </xsl:if>
       </xsl:attribute>
-
-      <!-- Test if this block has tests -->
-      <if>
-        <available file="${{blocks}}/{$block-name}/test"/>
-        <then>
-          <mkdir dir="${{build.blocks}}/{$block-name}/test"/>
-
-          <copy todir="${{build.blocks}}/{$block-name}/test" filtering="on">
-            <fileset dir="${{blocks}}/{$block-name}/test" excludes="**/*.java"/>
-          </copy>
-
-          <javac destdir="${{build.blocks}}/{$block-name}/test"
-                 debug="${{compiler.debug}}"
-                 optimize="${{compiler.optimize}}"
-                 deprecation="${{compiler.deprecation}}"
-                 target="${{target.vm}}"
-                 nowarn="${{compiler.nowarn}}"
-                 compiler="${{compiler}}">
-            <src path="${{blocks}}/{$block-name}/test"/>
-            <classpath>
-              <path refid="{$block-name}.classpath"/>
-              <path refid="test.classpath"/>
-              <pathelement location="${{build.test}}"/>
-            </classpath>
-          </javac>
-
-          <junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
-            <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
-            <jvmarg value="-Djunit.test.loglevel=${{junit.test.loglevel}}"/>
-            <classpath>
-              <path refid="{$block-name}.classpath"/>
-              <path refid="test.classpath"/>
-              <pathelement location="${{build.test}}"/>
-              <pathelement location="${{build.blocks}}/{$block-name}/test"/>
-            </classpath>
-            <formatter type="plain" usefile="no"/>
-            <formatter type="xml"/>
-            <batchtest todir="${{build.test.output}}">
-              <fileset dir="${{build.blocks}}/{$block-name}/test">
-                <include name="**/*TestCase.class"/>
-                <include name="**/*Test.class"/>
-                <exclude name="**/AllTest.class"/>
-                <exclude name="**/*$$*Test.class"/>
-                <exclude name="**/Abstract*.class"/>
-              </fileset>
-            </batchtest>
-          </junit>
-        </then>
-      </if>
+      <block-tests name="{$block-name}"/>
     </target>
 
     <target name="{@name}-prepare-anteater-tests" unless="internal.exclude.block.{$block-name}">
-      <!-- Test if this block has Anteater tests -->
-      <if>
-        <available file="${{blocks}}/{$block-name}/test/anteater"/>
-        <then>
-          <copy todir="${{build.test}}/anteater">
-            <fileset dir="${{blocks}}/{$block-name}/test/anteater"/>
-            <mapper type="glob" from="*.xml" to="{$block-name}-*.xml"/>
-          </copy>
-        </then>
-      </if>
+        <block-prepare-anteater-tests name="{$block-name}"/>
     </target>
   </xsl:template>
 </xsl:stylesheet>

Mime
View raw message