add JUnit
[jpim.git] / build.xml
index a0c6ac6..99ba17a 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,27 +1,55 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project name="PIMStuff" default="build" basedir=".">
 
-       <property name="src" location="src"/>
-       <property name="build" location="bin"/>
-       <property name="main" value="de.j32.pimstuff.Main"/>
+       <property name="src" location="src" />
+       <property name="build" location="bin" />
+       <property name="main" value="de.j32.pimstuff.Main" />
+       <property name="lib" value="libs" />
+       <property name="test" value="tests" />
 
        <target name="makedirs">
-               <mkdir dir="${build}"/>
+               <mkdir dir="${build}" />
        </target>
-       
-       <target name="build" depends="makedirs"
-                       description="Compile project to ${build} directory">
-               <javac srcdir="${src}" destdir="${build}"/>
+
+       <path id="classpath">
+               <fileset dir="${lib}">
+                       <include name="**/*.jar" />
+               </fileset>
+       </path>
+
+       <fileset id="tests" dir="${test}">
+               <include name="**/*.java" />
+       </fileset>
+
+       <target name="build" depends="makedirs" description="Compile project to ${build} directory">
+               <javac srcdir="${src}" destdir="${build}" classpathref="classpath" />
+       </target>
+
+       <target name="clean" description="Clean up ${build} directory">
+               <delete>
+                       <fileset dir="${build}" />
+               </delete>
+       </target>
+
+       <target name="run" depends="build" description="Start main class">
+               <java fork="true" classpath="${build}" classpathref="classpath" classname="${main}" />
        </target>
-       
-       <target name="clean"
-                       description="Clean up ${build} directory">
-               <delete><fileset dir="${build}"/></delete>
+
+       <target name="build-tests" depends="build" description="Compile tests">
+               <javac srcdir="${test}" destdir="${build}" classpath="${build}" classpathref="classpath" />
        </target>
 
-       <target name="run" depends="build"
-                       description="Start main class">
-               <java fork="true" classpath="${build}" classname="${main}"/>
+       <target name="test" depends="build-tests" description="Run JUnit tests">
+               <junit fork="true" printsummary="withOutAndErr" haltonerror="true">
+                       <classpath>
+                               <path refid="classpath" />
+                               <pathelement path="${build}" />
+                               <pathelement path="${test}" />
+                       </classpath>
+                       <batchtest>
+                               <fileset refid="tests" />
+                       </batchtest>
+               </junit>
        </target>
 
 </project>