View RSS Feed

My Java Tips

ANT Targets and Tasks

Rate this Entry
by , 11-19-2011 at 05:39 PM (776 Views)
In this post, I will talk about ANT targets and tasks.

Each buildfile contains at least one target within the project. One target can be dependent upon the another target.
Java Code:
<target name="A">
<target name="B" depends="A">
<target name="C" depends="B">
<target name="D" depends="C">
<target name="E" depends="D,C,B,A">
Suppose you want to execute target E, which depends upon D, C, B and A
D depends on C
C depends on B
B depends on A
First A is executed, then B, then C, then D and in the end E


Targets consists of tasks. It is a piece of code that can be executed. A task can have several attributes. The value of an attribute might contain references to a property. These references will be resolved before the task is executed.

Tasks have a common structure:
Java Code:
    <name attribute1="value1" attribute2="value2">
where name is the name of the task, attributeN is the attribute name, and valueN is the value for this attribute.

There are built-in tasks as well as optional tasks. You can also write your own tasks.

Submit "ANT Targets and Tasks" to Facebook Submit "ANT Targets and Tasks" to Digg Submit "ANT Targets and Tasks" to Submit "ANT Targets and Tasks" to StumbleUpon Submit "ANT Targets and Tasks" to Google