Author: nextgens
Date: 2008-09-07 11:35:25 +0000 (Sun, 07 Sep 2008)
New Revision: 22518

Modified:
   trunk/plugins/build.xml
Log:
plugins: tweak the buildfile so that we can have unit-testing there too

Modified: trunk/plugins/build.xml
===================================================================
--- trunk/plugins/build.xml     2008-09-07 11:30:08 UTC (rev 22517)
+++ trunk/plugins/build.xml     2008-09-07 11:35:25 UTC (rev 22518)
@@ -7,11 +7,15 @@
        <property name="svn.revision" value="@custom@"/>
        <property name="source-version" value="1.5"/>
        <property name="build" location="build/"/>
+       <property name="build-test" location="build-test/"/>
        <property name="dist" location="dist/"/>
+       <property name="junit.location" value="/usr/share/java/junit.jar"/>
        <available file="${what}/Version.java" property="version.present"/>
+       <available file="${junit.location}" property="junit.present"/>

        <target name="mkdir">
                <mkdir dir="${build}"/>
+               <mkdir dir="${build-test}"/>
                <mkdir dir="${dist}"/>
                <echo message="Using ${freenet-cvs-snapshot.location} as 
freenet-cvs-snapshot.jar"/>
                <echo message="Using ${freenet-ext.location} as 
freenet-ext.jar"/>
@@ -42,7 +46,44 @@
        </target>

        <!-- ================================================== -->
-       <target name="dist" depends="clean,compile"
+
+       <target name="unit-build" depends="compile" if="junit.present" 
unless="skip_tests">
+               <javac srcdir="${what}" destdir="${build-test}" debug="on" 
optimize="on" source="1.5">
+                       <classpath>
+                               <pathelement path="${build}"/>
+                               <pathelement 
location="${freenet-ext.location}"/>
+                               <pathelement 
location="${freenet-cvs-snapshot.location}"/>
+                               <pathelement location="${junit.location}"/>
+                       </classpath>
+                       <compilerarg value="-Xlint"/>
+                       <include name="**/*Test.java"/>
+               </javac>
+       </target>
+
+       <target name="junit" depends="unit-build" if="junit.present" 
unless="skip_tests">
+               <junit printsummary="yes" fork="yes" haltonfailure="yes">
+                       <classpath>
+                               <pathelement path="${build}"/>
+                               <pathelement path="${build-test}"/>
+                               <pathelement 
location="${freenet-ext.location}"/>
+                               <pathelement 
location="${freenet-cvs-snapshot.location}"/>
+                               <pathelement location="${junit.location}"/>
+                       </classpath>
+
+                       <formatter type="plain" usefile="false"/>
+
+                       <batchtest fork="yes">
+                               <fileset dir="${build-test}">
+                                       <include name="**/*Test.class"/>
+                               </fileset>
+                       </batchtest>
+                       <sysproperty key="benchmark" value="${benchmark}" />
+                       <sysproperty key="extensiveTesting" 
value="${extensiveTesting}" />
+               </junit>
+       </target>
+
+       <!-- ================================================== -->
+       <target name="dist" depends="clean,compile,junit"
                description="generate the distribution" >
                <jar jarfile="${dist}/${what}.jar" duplicate="fail">
                        <manifest>
@@ -58,6 +99,7 @@
        <!-- ================================================== -->
        <target name="clean" description="Delete class files and docs dir.">
                <delete dir="${build}"/>
+               <delete dir="${build-test}"/>
                <delete dir="${dist}"/>
        </target>
 </project>


Reply via email to