Anatomy of a Build File
Ant projects all revolve around one or more build files. By default, Ant looks for a build file named build.xml. Because Ant files are XML documents, they start with an XML declaration, as all valid XML documents must:
<?xml version="1.0" ?>
.
.
.Tip
For the complete XML 1.0 syntax, look at http://www.w3.org/TR/REC-xml/. XML 1.1 is out now as well, but Ant build files are based on XML 1.0, and the difference between these versions is small anyway, centering mostly on the manner in which certain Unicode characters are supported.
Projects
Every Ant build file contains exactly one
project. You set up an Ant project in a build
file with the project element,
which is the document element—i.e.,
the element that contains all other elements:
<?xml version="1.0" ?> <project> . . . </project>
As Ant build files are just XML, you'll need to know
which attributes are allowed on the top-level project element.
Tip
You'll also want to know about the elements that can be nested
within project. Those are dealt
with throughout the rest of this chapter and in Chapter 2.
The three allowed attributes for the project element are shown in Table 1-1.
Table 1-1. The project element's supported attributes
Attribute | Description | Required |
|---|---|---|
| Defines the project name | No |
| The target to invoke if no target is explicitly specified | Yes |
| The base directory from which all relative paths are resolved | No |
Note that the default attribute is required. This attribute points to the Ant target ...