Skip to content

Instantly share code, notes, and snippets.

@paretje
Last active October 17, 2016 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paretje/b015e1186857f2df01983ab4f2dcfbdd to your computer and use it in GitHub Desktop.
Save paretje/b015e1186857f2df01983ab4f2dcfbdd to your computer and use it in GitHub Desktop.
Basic ant build file
<project default="jar">
<property file="project.properties" prefix="project" />
<target name="clean">
<delete dir="build" />
</target>
<target name="compile">
<mkdir dir="build/classes" />
<javac includeantruntime="false" srcdir="src" destdir="build/classes" classpath="${project.classpath}" />
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/${project.name}.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="${project.main}" />
</manifest>
</jar>
</target>
<target name="run" depends="compile">
<java classpath="build/classes:${project.classpath}" classname="${project.main}" fork="true" />
</target>
<target name="debug">
<mkdir dir="build/debug"/>
<javac includeantruntime="false" srcdir="src" destdir="build/debug" classpath="build/classes:${project.classpath}" debug="true" />
</target>
<target name="compile-tests" depends="debug">
<mkdir dir="build/test"/>
<javac includeantruntime="false" srcdir="test" destdir="build/test" classpath="/usr/share/java/junit4.jar:build/debug:${project.classpath}" debug="true" />
</target>
<target name="test" depends="compile-tests">
<junit fork="yes" haltonfailure="yes">
<classpath>
<pathelement location="build/debug" />
<pathelement location="build/test" />
<pathelement location="/usr/share/java/junit4.jar" />
<pathelement path="${project.classpath}" />
</classpath>
<batchtest>
<fileset dir="build/test">
<include name="**/*Test*" />
</fileset>
</batchtest>
<formatter type="brief" usefile="false" />
</junit>
</target>
<target name="test-file" depends="compile-tests">
<java classpath="/usr/share/java/junit4.jar:build/debug:build/test:${project.classpath}" classname="org.junit.runner.JUnitCore" fork="true">
<arg value="${test}" />
</java>
</target>
</project>
name=project
main=Main
classpath=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment