Skip to content

Instantly share code, notes, and snippets.

@whymarrh
Created November 16, 2013 03:36
Show Gist options
  • Save whymarrh/7495604 to your computer and use it in GitHub Desktop.
Save whymarrh/7495604 to your computer and use it in GitHub Desktop.
Simple Ant build file.
<!--
Directory structure:
.
├── build.xml
├── libs
└── src
   └── foo
   └── bar
   └── baz
   └── qux
-->
<project name="Foobar" default="cleanrun" basedir=".">
<!-- Set global properties -->
<property name="srcdir" location="src" />
<property name="libs" location="libs" />
<property name="dist" location="dist" />
<property name="build" location="build" />
<path id="libs">
<fileset dir="${libs}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<tstamp />
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
</target>
<!-- Compile all the things -->
<target name="compile" depends="init" description="Compile all the Java files and put them into a JAR.">
<javac includeantruntime="false" srcdir="${srcdir}" destdir="${build}" debug="true">
<classpath refid="libs" />
<compilerarg value="-Xlint:all" />
</javac>
<jar jarfile="${dist}/${ant.project.name}-${DSTAMP}.jar" basedir="${build}">
<zipgroupfileset dir="${libs}" includes="**/*.jar" />
<manifest>
<attribute name="Main-Class" value="foo.bar.baz.qux.MainClassName" />
</manifest>
</jar>
</target>
<target name="cleanrun" depends="compile" description="Run the compiled JAR file.">
<delete dir="${build}" />
<java jar="${dist}/${ant.project.name}-${DSTAMP}.jar" fork="true" />
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment