Skip to content

Instantly share code, notes, and snippets.

@rchatley
Created June 25, 2012 17:54
Show Gist options
  • Save rchatley/2990197 to your computer and use it in GitHub Desktop.
Save rchatley/2990197 to your computer and use it in GitHub Desktop.
<project name="SimpleProject">
<property name="build.dir" value="build"/>
<property name="build.prod.dir" value="${build.dir}/prod"/>
<property name="build.test.dir" value="${build.dir}/test"/>
<property name="build.jar.dir" value="${build.dir}/jar"/>
<property name="src.dir" value="src"/>
<property name="unit.test.dir" value="unit-test"/>
<property name="system.test.dir" value="system-test"/>
<property name="lib.dir" value="lib"/>
<path id="classpath">
<pathelement location="${build.prod.dir}"/>
<pathelement location="${build.test.dir}"/>
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.prod.dir}"/>
<mkdir dir="${build.test.dir}"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" destdir="${build.prod.dir}" classpathref="classpath"/>
</target>
<target name="compile-tests">
<javac srcdir="${unit.test.dir}" destdir="${build.test.dir}">
<classpath>
<path refid="classpath"/>
<pathelement location="${build.prod.dir}"/>
</classpath>
</javac>
<javac srcdir="${system.test.dir}" destdir="${build.test.dir}">
<classpath>
<path refid="classpath"/>
<pathelement location="${build.prod.dir}"/>
</classpath>
</javac>
</target>
<property name="test.report.dir" value="${build.dir}/junitreport"/>
<property name="unit.test.report.dir" value="${build.dir}/junitreport/unit-test"/>
<property name="system.test.report.dir" value="${build.dir}/junitreport/system-test"/>
<target name="run-unit-tests" depends="compile,compile-tests">
<mkdir dir="${test.report.dir}"/>
<mkdir dir="${unit.test.report.dir}"/>
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="classpath"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${unit.test.report.dir}">
<fileset dir="unit-test/" includes="**/*Test.java"/>
</batchtest>
</junit>
<junitreport todir="${unit.test.report.dir}">
<fileset dir="${unit.test.report.dir}" includes="TEST-*.xml"/>
<report todir="${unit.test.report.dir}"/>
</junitreport>
<fail message="Unit tests failed. Check log and/or reports." if="test.failed"/>
</target>
<target name="jar" depends="run-unit-tests">
<jar destfile="${build.jar.dir}/Encrypt.jar" basedir="${build.prod.dir}">
<manifest>
<attribute name="Main-Class" value="com.develogical.crypto.Encrypt"/>
</manifest>
</jar>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment