About
How to control the flow in a build file.
Articles Related
Target
Dependency
depends
Targets can depend on other targets and Apache Ant ensures that these other targets have been executed before.
Each target gets executed only once, even when more than one target depends on it.
The below build file:
<target name="A"/>
<target name="B" depends="A"/>
<target name="C" depends="B"/>
<target name="D" depends="C,B,A"/>
will result on the following call graph:
A --> B --> C --> D
extension-point
An extension point can be seen as a target to be imported.
They have a name and a depends list and can be executed from the command line.
For example, the below build:
<target name="create-directory-layout"/>
<extension-point name="ready-to-compile" depends="create-directory-layout"/>
<target name="compile" depends="ready-to-compile"/>
</target>
will result in the following call-graph:
create-directory-layout --> --> compile
Adding the following target in the build (but mostly through an import):
<target name="generate-sources" extensionOf="ready-to-compile"/>
will result in the following call-graph
create-directory-layout --> generate-sources --> compile
if/unless
A target has the ability to perform its execution if (or unless) a property has been set.
Ant will only check whether the property has been set, the value doesn't matter
<target name="build-module-A" if="propertie-A-present"/>
<target name="build-module-A" unless="propertie-B-present"/>