Apache Ant Targets

A target is a collection of one or more tasks. Task is a piece of code and that is to be executed. A buildfile contains a project and inside the project all the targets are declared. To create a target, we can use <target> tag.

A target can depend on the other target and dependent target must execute before the current target. For example we might have a target for compiling and other one for run the code. Now, we can run target only after the compile target is executed. So the run target is depend on compile target. See an example.

Call-Graph: compile → run

Call graph represents the sequence of target execution.

Note: Each target executes only once, even when it has multiple dependent targets.

The target has various attributes that are given below.

AttributeDescriptionRequired
nameIt sets name of the targetYes
dependslist of targets on which it is depend.No
ifA property that evaluates to trueNo
unlessA property that evaluates to falseNo
descriptionA short description of this target?s functionNo
extensionOfAdds the current target to the dependent list of extension point.No
onMissingExtensionPointWhat to do if this target extends a missing extension pointNo

The name attribute can be any valid alphanumeric string.





Latest Courses