Ant Fundamentals
Before we look at using Ant for tasks specific to enterprise application development, let’s run through the basic mechanics of Ant, for readers who haven’t used Ant before. If you’ve used Ant before, you can skip this section and jump right to "Enterprise Tasks" later in this chapter.
Buildfiles
When you execute Ant, you specify a command file that it
should use to load the definitions of targets. The buildfile uses an
XML format to define the targets and the tasks involved in running
each target. The root XML element of the buildfile is always a
<project>
element, which
defines the name of the project and the default target that the
buildfile will execute (if you don’t specify one when invoking Ant).
The <project>
element in
Ant buildfiles supports the attributes listed in Table 17-1.
Table 17-1. Project element attributes
Attribute name | Purpose | Required |
---|---|---|
name
| Descriptive name of the project,
sometimes used by IDEs and other tools to describe a
particular project buildfile. The project name can be
accessed in the buildfile using the | No |
default
| Name of the default target to be invoked when Ant is invoked on this buildfile with no specific target specified. | Yes |
basedir
| The root directory where Ant will
execute all targets and tasks in this buildfile. This base
directory will be the starting point for any relative paths
used in the buildfile. The base directory can also be
specified using the |
Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.