Ant Documentation Stylesheet

Apache’s Ant has taken the Java development community by storm, supplementing traditional Java IDEs and outright replacing Makefiles on most Java development projects. Ant is a build tool, similar to the make utility, only it uses XML files instead of Makefiles. In addition to a portable build file based on XML, Ant itself is written in Java and has few platform-specific dependencies. Finally, since Ant can reuse the same running instance of the Java Virtual Machine for nearly every step of the build process, it is blazingly fast. Ant can be downloaded from http://jakarta.apache.org and is open source software.

Ant Basics

Ant is driven by an XML build file , which consists of one project . This project contains one or more targets , and targets can have dependencies on one another. The project and targets are represented as <project> and <target> in the XML build file; <project> must be the document root element. It is common to have a “prepare” target that builds the output directories and a “compile” target that depends on the “prepare” target. If you tell Ant to execute the “compile” target, it first checks to see that the “prepare” target has created the necessary directories. The structure of an Ant build file looks like this:

<?xml version="1.0"?> <project name="SampleProject" default="compile" basedir="."> <!-- global properties --> <property name="srcdir" value="src"/> <property name="builddir" value="build"/> <target name="prepare" description="Creates ...

Get Java and XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.