Transcript ANT

Apache ANT
A platform independent build tool for
Java programs.
http://ant.apache.org/
Winter 2005
Jason Prideaux
1
ANT – A build tool for Java




ANT is similar to make, gnumake, etc.
It is designed for and written in Java.
Thus, it is a platform independent.
It is the de facto standard for open source
Java projects.
Ideal for large, complex software projects.
Winter 2005
Jason Prideaux
2
ANT – A build tool for Java


Build files are written in standard XML as
opposed to a specialty language.
One build file can be used to set classpath,
compile and run your program, generate
javadocs, create jars, perform CVS
commands, and much more.
Winter 2005
Jason Prideaux
3
ANT – Build files
ANT build files contain the following XML
tags:
 Project – The name and location of your
software program/project.
 Properties – Global variables.
 Targets – Tasks/commands that ANT can
perform.
Winter 2005
Jason Prideaux
4
ANT – Example build file

You start by declaring your project in the
xml build file.
<project name=“Simplechat" default=“compile" basedir=".">
<description>
Build file for simplechat. (optional)
</description>
…
</project>
Winter 2005
Jason Prideaux
5
ANT – Example build file

Next, add properties to the XML file, such
as classpath, code directories, compile
destinations, etc.
…
<property name="source" location=“simplechat4"/>
<property name=“classes" location=“simplechat4 "/>
<property name="classpath" value=“.:simplechat4" />
…
Winter 2005
Jason Prideaux
6
ANT – Example build file

Lastly, add targets to the XML file, which
can correspond to commands like javac,
java, cvs, etc.
<target name="compile" >
<javac srcdir="${source}" destdir="${classes}"/>
<classpath>
<pathelement path="${classpath}"/>
</classpath>
</javac>
</target>
Winter 2005
Jason Prideaux
7
References

http://ant.apache.org/
Winter 2005
Jason Prideaux
8