Calling Other Ant Tasks
You've seen that you can branch using true/false
properties. Ant provides other powerful mechanisms for branchingthe
antcall task, which you can use to
call one Ant task from another, and the ant task, which calls Ant tasks in other build
files.
Calling Ant Tasks in the Same Build File
A better way to think of antcall is that you're starting a new
instance of Ant and executing targets in it. When you call an Ant
target with antcall, its dependent
targets are executed in order, something that can be confusing if you
think you're calling a single target. Generally, it's best to do
things the standard way and let Ant sort out the dependencies as it's
supposed to. However, Ant can make life easier, as when you have a
build file that creates a distribution for many different servers, and
when varying sets of tasks need to be executed for each. (Even in
cases like that, however, you can still set things up easily enough
with if and unless and true/false properties.)
When you use antcall, you can
think of that call as creating a new project; all the properties of
the current project are available in that new project by default. The
attributes of the antcall task
appear in Table
3-4.
Table 3-4. The antcall attributes
Attribute | Description | Required | Default |
|---|---|---|---|
| If true, means the task should pass all current properties to the new Ant project. Properties passed to the new project will override the properties that are set in the new project. | No | true |
|