Ant Developer's Handbook

Alan Williamson / Andrew Wu / Joey Gibson / Kirk Pepperdine  
Sams Publishing
Total pages
October 2002

Product detail

Title no longer available


The authoritative word on Ant, a hot new open source build tool for Java.

Table of Contents

(NOTE: Each chapter concludes with a Summary.)

1. Introduction to Ant.

In the Beginning. The First Ant Project. Ant Terminology. Should I Use Ant?

2. Preliminaries.

How to Get Ant. How to Install Ant. A Tour of Ant with a Small Exercise.

3. Global Concepts.

Developing in a Standard Directory Tree. Creating Standard Ant Targets and What They Should Do. Exploring Ant Data Types. Listeners and Loggers. Predefined Properties. The Ant Command Line.

4. Built-In Tasks.

Common Attributes of All Tasks. <ant>. <antcall>. <antstructure>. <apply>/<execon>. <available>. <basename>. <buildnumber>. <Bunzip2>. <BZip2>. <checksum>. <chmod>. <concat>. <condition>. <Copy>. <copydir>. <copyfile>. <cvs>. <cvschangelog>. <cvspass>. <cvstagdiff>. <delete>. <deltree>. <dependset>. <dirname>. <ear>. <echo>. <exec>. <fail>. <filter>. <fixcrlf>. <genkey>. <get>. <gunzip>. <gzip>. <input>. <jar>. <java>. <javac>. <javadoc> and <javadoc2>. <loadFile>. <loadproperties>. <mail>. <manifest>. <mkdir>. <move>. <parallel> and <sequential>. <patch>. <pathconvert>. <property>. <record>. <rename>. <replace>. <rmic>. <sequential>. <signjar>. <sleep>. <sql>. <style>. <tar>. <taskdef>. <touch>. <tstamp>. <typedef>. <Unjar>, <Untar>, <Unwar>, <Unzip>. <uptodate>. <waitfor>. <war>. <xmlproperty>. <xslt>. <zip>.

5. Optional Tasks.

Additional Resources for Ant. ANTLR. <cab>. <depend>. <echoproperties>. <ftp>. <icontract>. <propertyfile>. <javacc>. <jjtree>. <javah>. <jspc>. <junit>. <junitreport>. <replaceregexp>. <setproxy>. <sound>. <splash>. <telnet>. <xmlvalidate>.

6. Extending Ant with Custom Tasks, Data Types, and Listeners.

Matching Class to Source. Life Cycle of a Task. An Informal Contract for a Custom Task. Requirements for ClassToSource. An Implementation for ClassToSource. Adding Nested Elements to a Custom Task. Custom DataTypes. A Custom DataType for ClassToSource. Using a Predefined Data Type. Custom Listeners.

7. Troubleshooting Ant Build Scripts.

Common Debugging Techniques. Syntax Errors. Semantic Errors. Programmatic Errors. Ant Message Levels. Using a Java Debugger. Support Resources and Rules of Engagement. Common Problems and Solutions.

8. Performing End to End Builds on a Nightly Basis.

What Is End to End Building? Targets for EtE Builds.

9. Ant in the Real World.

The Large Sample Application. A Standard Build Environment. Decomposing the Build. Ant Properties. Standard Build Targets. Building the Channel Component. Building the Common Layer. Building the Chat Server. Building the Chat Client. A One-Shot Build of the ChatRoom Application. Some Benefits of Chaining Builds.

10. The Future Direction of Ant.

Ant 2. What Can I Do to Help?

11. Tool Support for Ant.

Ant Farm for jEdit. AntRunner for JBuilder. Sun ONE Studio (AKA Forte for Java). Eclipse. CruiseControl. Control Center. IntelliJ IDEA 2.5.


Back Cover

Ant has emerged as the preferred building tool for Java developers, automating tedious compilation, test, and code management. Many Java developers are aware of Ant but there is little documentation to assist in getting started with the Ant tool. Even experienced developers who already use some of the features of the Ant tool, struggle with the more advanced aspects. This book will educate those devlopers in these more advanced topics, and help them get more out of the tool. The Ant Developer's Handbook begins with a rapid introduction to obtaining, installing, and configuring Ant and covers all major feature sets and use practices.

Ant is a cross-platform build and configuration management tool. It is written in Java, and uses XML as its file format, thereby allowing entire development teams to share Ant build files, regardless of the operating system each developer is using. Ant can perform nearly any common configuration management function, including:

  • compiling application source code.
  • running test suites and building archive files.
  • moving/copying files to server machines.
  • interacting with source control systems.


Alan Williamson is as much a veteran of the Java world as one can be with a language that is still very much finding its feet in the world. Alan has more than 15 years experience in the world of software development, graduating with full honors in computer science from the University of Paisley. Alan worked in mainly research and development roles until starting up the UK's first pure Java consultancy company five years ago, specializing in Java on the server side ( Alan has also worked his way up to the dizzy heights of editor-in-chief of the world's largest Java magazine, Java Developers Journal, and can be found talking at various conferences all over the place!

Kirk Pepperdine has more than 15 years of experience in informatics. During that time, he has focused on applying object-oriented methodologies and technologies to the field of distributed computing, where Kirk has functioned as a researcher, developer, designer, architect, and consultant. Kirk has been heavily involved in the performance aspects of applications since the start of his career, and has tuned applications involving a variety of languages from Cray Assembler through C, Smalltalk, and on to Java. Kirk has focused on Java since 1996. He can be reached at

Joey Gibson has been working in the technology industry since 1990. He is a Sun Certified Programmer for the Java 2 Platform and has been working with Java since early 1996. He is a Senior Consultant and instructor for BravePoint (, located in Atlanta, GA, specializing in J2EE development. He is a "collector" of programming languages whose favorites include Java, Smalltalk, Ruby and Python. He can be reached at or

Andy Wu has been involved in software development for more than five years. He is a software enthusiast who thrives on new technologies. Andy currently applies his Java expertise as a developer at n-ary consultancy in Scotland. Prior to joining n-ary, he worked in research and development roles, and achieved a full honours degree in software engineering from the University of Glasgow.