Ant Tag Reference

Another Neat Tool (Ant), despite its modest name, is a powerful platform-independent build tool. By creating XML files to develop build tasks, you can extend Ant to solve a host of problems, taking it far beyond simple code compilation. Ant's focus on code completion and app building is its strength and weakness. Ant does solve some problems programmatically. However, it is not intended to be a coding language. This reference covers most of Ant's built-in tasks and a few optional tasks that relate to the content of this tutorial. The task descriptions are concise and organized into logical groupings for easier reference.

Ant Command Line Options

After following Ant's installation instructions, you can execute build.xml files by simply typing "ant" at the command prompt. If you're using someone else's buildfile, you should investigate its purpose and functionality before running it. If the creator of the buildfile has described its main tasks, that extended help/usage will be available using the projecthelp switch. Throughout this chapter, an asterisk (*) after a parameter name indicates that this is a required parameter in the task's simplest form. The general syntax for the ant command line is as follows:

ant [options] [target [target2 [target3] ...]]

Simple buildfiles won't require most of these switches. However, if your buildfile is not named build.xml, you will need to specify the buildfile's name by using the -buildfile option; to execute a target other than the default, use the following:

ant -buildfile [ANT file] [target]

Command line options displayed from Ant's help option are as follows:

-help print this message
-projecthelp print project help information
-version print the version information and exit
-quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
-emacs produce logging information without adornments
-logfile [file] use given file for log output
-logger [classname] the class that is to perform logging
-listener [classname] add an instance of class as a project listener
-buildfile [file] use specified buildfile
-find [file] search for buildfile towards the root of the
 filesystem and use the first one found
-Dproperty=[value] set property to value

XML Tag

Ant uses XML files to execute. The default name of Ant's XML file is build.xml. If an Ant user types "ant" with no other commands, Ant will attempt to open build.xml. Ant's build.xml file must contain the XML version and encoding:

<?xml version="1.0" encoding="UTF-8"?>

If you are not familiar with XML encoding, be aware that comments are written as follows:

<!-- comment goes here -->