Ant Key Tasks

A key task is something that must be done for Ant. In contrast, most other tasks have more to do with accomplishing things for the app we are building.

Ant Task

The ant task executes an Ant buildfile from the currently executing Ant script:

<ANT antfile="[ant file name]"/>

It will execute the project's default target.

Parameters

Antcall Task

The antcall task executes an Ant target:

<antcall target="[target]"/>

All of the dependent Ant targets will execute, followed by the specific target specified.

Parameters

Nested Parameters

This example will set a property to a value when the antcall task is executed:

<antcall target="[target name]">
<param name="[property]" value="[property value]"/>
</antcall>

Available Task

You can use the available task to determine if a file, class, or Java Virtual Machine (JVM) system property is available. If it is not present, the task sets the value of a given property to "false" (the value defaults to "true"). In the following example, if the file is not available, the property will be set to "false":

<available file="[resource]" property="[property]"/>

Parameters

Nested Parameter

Echo Task

The echo task sends message to Ant's system output or to a specified file:

<echo message="Hello world"/>
<echo>
This is a longer message stretching over two lines.
</echo>

Parameters

Fail Task

The fail task stops execution of the current build:

<fail/>

Parameter

Property Task

The property task creates properties by assigning values to names. Properties set outside the current Ant project cannot be reassigned in the current Ant project:

<property name="[property]" value="[property value]"/>

Parameters

Nested Parameter

Taskdef Task

The taskdef task creates a custom task by executing Java classes:

<taskdef name="[task]" classname="[java class]"/>

Parameters