How ANT works?
Each Project will have a build file (build.xml)
Each build file will contain one or more Targets
Java – Download Free EBooks and Whitepapers
The Target to be executed:
Is either explicitly selected on the command line
Or a project default Target is executed
Java™ Application Development on Linux® – Free 599 Page eBook |
Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications: |
||||
Each Target is executed only once.
Project
is the top level element in an Ant script
<project> has three optional attributes:
name: the name of the project
default: the default target to use when no target is supplied
basedir: the base directory from which all path calculations are done
<project name=“MyProject” default=“compile”>
<!–- properties and targets will come here…–>
</project>
Targets
Each project defines zero or more targets
A target is a set of tasks you want to be executed
When starting Ant, you can select which target(s) you want to have executed
When no target is given, the project’s default is used
Targets can be conditionally executed (using if/unless)
A target can depend on other targets
Target dependencies are transitive
Each Target will contain one or more Tasks
Some Tasks are executed conditionally
Tasks are implemented as Java classes
<project name=“MyProject” default=“compile”>
<property name=”buildDir” value=”build”/>
<property name=“srcDir” value=“.”/>
<target name=”compile”>
<!–Tasks will come here…–>
</target>
</project>
Tasks
A task is a piece of code that can be executed
A task can have multiple attributes (a.k.a arguments)
The value of an attribute might use the value of a property.
Ant comes with over 80 core tasks, and 60 optional tasks
Ant task extensions can be easily written for any unique problem
<project name=“MyProject” default=“compile”>
<property name=”buildDir” value=”build”/>
<property name=“srcDir” value=“.”/>
<target name=”compile”>
<javac srcdir=”${srcDir}” destdir=”${build}”/>
</target>
</project>