Ant target:compile
<?xml version="1.0"?> <project name="sample" default="test" basedir="."> <target name="compile"> <mkdir dir="build"/> <javac destdir="build" debug="on" optimize="on"> <src path="src"/> </javac> </target> <target name="test" depends="compile"> <java fork="no" failonerror="yes" classname="test.TestSample" classpath="build"> <arg line=""/> </java> </target> <target name="clean"> <delete dir="build"/> </target> </project>