by, 11-19-2011 at 05:43 PM (404 Views)
In this post, I will present a sample build.xml file for a simple Java "Hello, world" application and will explain the ANT project.
Please refer to the code above. You know that the Ant's buildfiles are written in XML. Each buildfile contains one project and at least one default target. Targets in turn contain task elements. Each task element of the buildfile can have an id attribute and can later be referred to by the value supplied to this. This value has to be unique.Java Code:<project name="HelloWorld" default="compile"> <target name="compile"> <javac srcdir="."> </javac></target> <target name="run" depends="jar"> <java classname="HelloWorld"> classpath = "HelloWorld.jar" fork = "true" /> </java></target> </project>
A project is the top level element in an Ant script. It has three optional attributes:
name - is the name of the project
default - is the default target to use when no target is supplied
basedir - is the base directory from which all path calculations are done