Introducing Ant


Ant is an extensible build utility from Apache Software Foundation that uses an XML-based syntax for creating build scripts. The build utility is open source and is available for download from the Apache Website at http://ant.apache.org.

Ant almost needs no introduction, as it has become the de facto standard for Java builds. As discussed in earlier chapters, XDoclet, Middlegen, and AndroMDA all rely on Ant for execution.

Chapter 7 discusses Middlegen and Chapter 8 introduces AndroMDA.


Ant's success is due to a number of features that see the build tool ideally suited to Java development. Ant's use of XML documents for defining build files offers a clean and readily understandable syntax, making it possible for developers to get quickly up to speed with the tool. This was a significant problem with earlier Make tools whose declarative semantics were often difficult to grasp.

Furthermore, Ant is implemented in Java and runs under any compliant JVM. This makes Ant a crossplatform build utility, an important factor when working with the J2SE platform. This is also a big advantage over previous Make tools, which rely on platform-specific shell commands for performing build operations.

Due to its huge uptake, Ant has grown into a mature build tool that offers an extensive range of features for performing just about every conceivable build task. Under Ant, build files invoke build operations by calling Ant tasks.

Ant provides a set of core inbuilt tasks that perform many of the common build operations, including:

  • Compiling Java source

  • Defining build classpaths

  • Generating Javadocs

  • Copying and deleting files

  • Changing file permissions

  • Creating JAR files

  • Executing external applications

  • Invoking build steps in other Ant build files

  • Working with archive formats, such as ZIP and TAR

  • Sending mail

  • Accessing source control repositories

Where Ant does not support a specific build operation, developers can implement their own custom Ant tasks, which are then accessible from within the build file.

Most major Java software vendors supply Ant tasks for controlling the build process when using their software. The code generators of XDoclet, Middlegen, and AndroMDA all supply Ant tasks specifically for this purpose.

With Ant's ubiquity in the Java world, you will likely use Ant for controlling all of your builds. Consequently, the next sections focus on the use of Ant for designing and implementing optimal build solutions.

Key Features of Ant

Here are some of the reasons Ant has proven so popular:

  • Ease-of-use through a simple XML-based scripting language

  • Crossplatform supportAnt executes under any compliant JVM

  • Extensive functionality through a wide range of built-in tasks

  • Extensible model through the definition of custom Ant tasks in Java

  • A de facto standardsoftware vendors supply Ant tasks by default

  • A large user base, meaning most software engineers have experience with Ant build files




    Rapid J2EE Development. An Adaptive Foundation for Enterprise Applications
    Rapid J2EEв„ў Development: An Adaptive Foundation for Enterprise Applications
    ISBN: 0131472208
    EAN: 2147483647
    Year: 2005
    Pages: 159
    Authors: Alan Monnox

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net