Skip to content

Instantly share code, notes, and snippets.

@barnash
Created July 31, 2010 08:36
Show Gist options
  • Save barnash/501940 to your computer and use it in GitHub Desktop.
Save barnash/501940 to your computer and use it in GitHub Desktop.
<project name="myproject-test" default="test" basedir=".">
<property name="src.dir" value="src" />
<property name="build.dir" value="build" />
<property name="reports.dir" value="reports"/>
<property name="tested.jar.file" value="myproject.jar"/>
<property name="junit.reports.dir" value="${reports.dir}/junit"/>
<path id="project.classpath">
<pathelement location="lib/junit-4.4.jar"/>
<pathelement location="${tested.jar.file}"/>
<pathelement location="${build.dir}"/>
</path>
<target name="get" description="Get the project from hudson">
<property name="project.build.number" value="lastSuccessfulBuild"/>
<get src="http://localhost:8080/job/myproject-build/${project.build.number}/artifact/myproject/dist/myproject.jar" dest="./"/>
</target>
<target name="compile" description="Compile the project">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" srcdir="${src.dir}" debug="true">
<classpath refid="project.classpath"/>
</javac>
</target>
<target name="test" depends="compile" description="Run the tests of the project">
<mkdir dir="${junit.reports.dir}"/>
<junit fork="yes" failureproperty="junit.failed" printsummary="yes" showoutput="yes">
<classpath refid="project.classpath"/>
<formatter type="xml"/>
<test name="com.myproject.FooTest" todir="${junit.reports.dir}"/>
</junit>
<fail if="junit.failed" message="Tests failed"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${reports.dir}"/>
<delete file="${tested.jar.file}"/>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment