Skip to content

Instantly share code, notes, and snippets.

@eman41
Created May 17, 2013 21:45
Show Gist options
  • Save eman41/5602211 to your computer and use it in GitHub Desktop.
Save eman41/5602211 to your computer and use it in GitHub Desktop.
Super basic ANT build for a standard java project. Uses a src/test/bin/lib/dist project structure.
<project name="Project" default="dist" basedir=".">
<property name="version" value="0.0"/>
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="dist" location="dist"/>
<property name="test" location="test"/>
<property name="lib" location="lib"/>
<path id="project.class.path">
<pathelement path="${build}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- Test and Generate Runtime -->
<target name="test-deploy"
depends="test,dist"
description="Test and generte distribution" />
<target name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
<target name="init" depends="clean">
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init">
<javac includeantruntime="false"
srcdir="${src}" destdir="${build}">
<classpath refid="project.class.path" />
</javac>
</target>
<target name="compile-test" depends="init">
<javac includeantruntime="true"
srcdir="${test}" destdir="${build}">
<classpath refid="project.class.path" />
</javac>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist}"/>
<jar jarfile="${dist}/project-${version}.jar" basedir="${build}"/>
</target>
<target name="test" depends="compile,compile-test">
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<classpath refid="project.class.path" />
<batchtest fork="yes">
<fileset dir="${test}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment