Skip to content

Instantly share code, notes, and snippets.

@jungomi
Last active November 11, 2015 06:57
Show Gist options
  • Save jungomi/998476f95eb4719ad3ed to your computer and use it in GitHub Desktop.
Save jungomi/998476f95eb4719ad3ed to your computer and use it in GitHub Desktop.
ant build for simple java project
<?xml version="1.0" encoding="UTF-8"?>
<project name="PROJECT" default="default" basedir=".">
<property name="version" value="1.8"/>
<property name="build.dir" value="build"/>
<property name="doc.dir" value="doc"/>
<property name="src.dir" value="src"/>
<property name="jar.name" value="JAR.jar"/>
<property name="main.class" value="MAINCLASS"/>
<property name="args" value=""/>
<target name="all" depends="jar, doc, run"/>
<target name="default" depends="run"/>
<target name="dist" depends="jar, doc"/>
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${doc.dir}"/>
</target>
<target name="run" depends="compile">
<java dir="${basedir}" classpath="${build.dir}" classname="${main.class}" fork="true">
<arg line="${args}"/>
</java>
</target>
<target name="jar" depends="init, compile">
<jar basedir="${build.dir}" jarfile="${jar.name}">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
</target>
<target name="compile" depends="init">
<javac
source="${version}"
target="${version}"
srcdir="${src.dir}"
destdir="${build.dir}"
includeantruntime="false"
/>
</target>
<target name="doc" depends="init">
<javadoc sourcepath="${src.dir}" destdir="${doc.dir}"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${doc.dir}"/>
<delete file="${jar.name}"/>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment