| Table of Contents |
Another Neat Tool (Ant) is a Java-based build tool that allows you to automate the build process of software. The build process compiles, links, and archives the files required to build software for use and distribution. Ant provides an extensible architecture that allows you add a new Java class to Ant to extend its functioning. The platform-independence property of Java allows you to use Ant on any computer that supports the Java run time.
This chapter introduces Ant. It explains how to set up an environment to install, configure, and build Ant. It also describes how to work with the Ant buildfile and run Ant.
Apache Ant is an open-source, cross-platform build tool from Apache Software Foundation, which is available in binary and source forms. Ant is an XML -based build tool, built in Java. The XML feature allows the buildfiles of Ant to be more descriptive and the Java feature allows Ant to be platform independent.
Ant is a command-line driven program that uses an XML file to describe the build process and store the build information. The XML file specifies rules, actions, and targets for the building process of the application. This XML file is named build.xml, by default, if you do not specify a file name for the buildfile in the current directory. The buildfile contains various tasks that Ant executes. The buildfile uses certain built-in commands of Ant to perform specific operations, such as copying and removing a directory and packaging a set of files.
| Note |
The make tool is a C and C++ based build tool that helps automate the build process of the application. The parameter of the make tool is makefile. |
Table 1-1 lists the built-in commands of Ant:
|
Command |
Description |
|---|---|
|
ant |
Executes another Ant process from within the existing process. |
|
copydir |
Copies a directory. |
|
copyfile |
Copies a file. |
|
concurrent versions system (cvs) |
Provides the ability to track and potentially revert incremental changes to files, reporting the changes to a mailing list as they occur. |
|
delete |
Removes either one file or all files from a specified directory and its subdirectories. |
|
deltree |
Removes a directory and all the files and subdirectories that it contains. |
|
exec |
Executes a system command. |
|
get |
Retrieves a file from a Uniform Resource Locator (URL). |
|
jar |
Packages a set of files. |
|
java |
Executes a Java class within the running Ant Virtual Machine (VM) or forks another VM if the fork attribute is set to true. |
|
javac |
Compiles a source tree within the running Ant VM. Forks another VM if the fork attribute is set to true. |
|
javadoc/Javadoc2 |
Produces code documentation using the javadoc tool. |
|
property |
Provides the default value of the property attribute to build the application. In buildfiles, you retrieve or set the values of property names from the property files using the <property> tag in the buildfile. |
|
rmic |
Executes the Remote Method Invocation (RMI) compiler for a specific class file. |
|
tstamp |
Sets the DSTAMP, TSTAMP, and TODAY properties in the current project. |
|
style |
Processes a set of documents using Extensible Stylesheet Language Transformation (XSLT). |
Ant allows you to build your own code and add new functions to the code by adding a new Java class. The various benefits of Ant are:
Allows you to build large-scale, multi-teamed projects.
Allows you to develop Java 2 Enterprise Edition (J2EE) applications.
Allows you to build Java Archive (JAR) files.
Allows remote work, such as remote building, using JAR files.
Allows you to build open-source projects.
Extracts the source from a version control system.
Builds directories.
Removes directories.
Compiles code.
Produces javadoc.
Builds JAR files.
Copies files.
Generates e-mail.
Executes SQL commands.
Performs unit tests.
| Table of Contents |