Apache Ant - Flow (Dependency, Condition)

Card Puncher Data Processing

About

How to control the flow in a build file.

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"/>

Documentation / Reference





Discover More
Card Puncher Data Processing
Apache Ant - Property

Properties are key-value-pairs where Apache Ant tries to expand to value at runtime. The key name is case-sensitive. Properties: permit to customize a build process provide shortcuts for strings...
Card Puncher Data Processing
Apache Ant - Target

A target is a grouping of tasks designed to do a particular job. Targets can declare other targets that they depend on. In a build, targets are the unit of incremental build. The default target...



Share this page:
Follow us:
Task Runner