Ant PDF
Ant PDF
Ant PDF
An Introduction to Ant
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
1
JAVA Means DURGASOFT
Index
Installing Ant
Ant Setup
Project Organization
Anatomy of a Build File
Projects
Build File
Properties
Build File with Properties
Targets
Build File with Targets
Tasks
Initialization Target & Tasks
Compilation Target & Tasks
Javadoc Target & Tasks
Cleanup Target & Tasks
Completed Build File (1 of 2)
Completed Build File (2 of 2)
Running Ant Command Line
Running Ant Eclipse
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
2
JAVA Means DURGASOFT
What is Ant?
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
3
JAVA Means DURGASOFT
Installing Ant
Ant can be downloaded from http://ant.apache.org/
Ant comes bundled as a zip file or a tarball
Simply unwrap the file to some directorywhere you want to store the executables
I typically unwrap the zip file into C:\ProgramFiles, and rename to C:\Program Files\ant\
This directory is known as ANT_HOME
Ant Setup
Project Organization
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
4
JAVA Means DURGASOFT
Projects
The project tag is used to define theproject you wish to work with
Projects tags typically contain 3 attributes
name a logical name for the project
default the default target to execute
basedir the base directory for which alloperations are done relative to
Additionally, a description for the projectcan be specified from within the project tag
Build File
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
5
JAVA Means DURGASOFT
Properties
Build files may contain constants (knownas properties) to assign a value to avariable which
can then be usedthroughout the project
Makes maintaining large build files moremanageable
Projects can have a set of properties
Property tags consist of a name/value pair
Analogous to macros from make
Targets
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
6
JAVA Means DURGASOFT
Tasks
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
7
JAVA Means DURGASOFT
Our compilation target will compile all javafiles in the source directory
The javac task compiles sources into classes
Note the dependence on the init task
<project name="Sample Project" default="compile" basedir=".">
...
<!-- Compile the java code in ${src.dir} into ${build.dir} -->
<target name="compile" depends="init" description="compile java sources">
<javacsrcdir="${source.dir}" destdir="${build.dir}"/>
</target>
...
</project>
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
8
JAVA Means DURGASOFT
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
9
JAVA Means DURGASOFT
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
10
JAVA Means DURGASOFT
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
11
JAVA Means DURGASOFT
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
12
JAVA Means DURGASOFT
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786
13