Sample Ant file
Friday, January 28th, 2011Every once in awhile I go back and try to figure out how to create a basic ant build.xml file. So I am just placing a sample build.xml here.
The directory structure should be something like
./build.xml
./src/HelloWorld.java
The targets will create the build directory and compile the source and run a test execution of the class.
<project name="HelloWorld" basedir="." default="main"> <target name="clean"> <delete dir="build"/> </target> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes"/> </target> <target name="jar" depends="compile"> <mkdir dir="build/jar"/> <jar destfile="build/jar/HelloWorld.jar" basedir="build/classes"> <manifest> <attribute name="Main-Class" value="HelloWorld"/> </manifest> </jar> </target> <target name="run" depends="jar"> <java jar="build/jar/HelloWorld.jar" fork="true" /> </target> <target name="main" depends="clean,run"/> </project>
Tags: ant