Category Archives: ant

Ant: Simple build file

build.xml

<?xml version="1.0"?>
<project name="ant test project" default="dist" basedir=".">

	<property name="src" location="src"/>
	<property name="build" location="build"/>
	<property name="dist"  location="dist"/>

	<target name="init">
		<tstamp/>
		<mkdir dir="${build}"/>
	</target>

	<target name="compile" depends="init" >
		<javac srcdir="${src}" destdir="${build}"/>
	</target>
	
	 <target name="dist" depends="compile" >
		<mkdir dir="${dist}/lib"/>
		<jar jarfile="${dist}/lib/${DSTAMP}-${TSTAMP}.jar" basedir="${build}"/>
	</target>
	
	<target name="clean" description="clean up" >
		<delete dir="${build}"/>
		<delete dir="${dist}"/>
	</target>
  
</project>

To run this

>ant -f build.xml
for specific task (eg. clean)
>ant -f build.xml clean
Advertisements