The Basics
Ant uses an XML syntax for its build files. A typical Ant file looks like this:
<project name="MyProject" default="compile" basedir=".">
<target name="init">
<tstamp/>
<mkdir dir="build"/>
</target>
<target name="compile" depends="init" description="compile the source" >
<javac srcdir="src" destdir="build"/>
</target>
</project>Even if you have no prior experience with Ant, it is very easy to read and understand.
Note
A build file is an XML file, usually called build.xml, with a collection of functions and variables (or targets and properties, as Ant calls them).
If we go through the preceding example, we see one project
definition. (An Ant file can contain only one.) Its default is set to
“compile,” meaning that when you run this file, the first function or
target that runs is the compile target. The name of a target can be
anything, as long as it is a string of text and numbers. So using “1 - My
very cool function” is perfectly legal. (I prefer a long, descriptive
target name, because it makes it easier to read in Eclipse’s Ant panel.
But, if you prefer, you can also add a description property in the target
to describe what that target does. The downside here is that when you let
that target depend on another target, you have to type out its full name.
But I’ll cover this topic more later.) The compile target has a depends property, which is set to “init.” This, in turn, runs the init target before it runs the compile target. It also creates a timestamp and a directory ...