Thursday, June 2, 2011

Ant Basics

The documentation for the installation is written under the assumption that the reader has some experience of installing software on computers and knows how to change the operating environment of the particular operating system they are using. The documents entitled Configuring A Windows Working Environment and Configuring A Unix Working Environment are of use to people who need to know more.

  1. Download the binaries from http://jakarta.apache.org/ant/index.html, unzip them to a suitable directory.

  2. Append /path/to/ant/bin to the PATH environment variable.

  3. Append the .jar files in /path/to/ant/lib/ to the CLASSPATH environment variable. Set JAVA_HOME to point to the location of the JDK installation on the machine that the software is being installed on. Append/path/to/jdk/lib/* to the CLASSPATH environment variable.

The installation instructions provided with the Ant software installation download are clear enough to warrant abstaining from writing any more about the installation here. Refer to/path/to/ant/docs/manual/install.html.

An Ant build file comes in the form of an XML document, all that is required is a simple text editor to edit the build file(s). An editor that provides XML syntax highlighting is preferable. The Ant installation comes with a JAXP-Compliant XML parser, this means that the installation of an external XML parser is not necessary.

A simple Ant example is shown below followed by a set of instructions indicating how to use Ant. It is recommended that the reader follow these instructions to gain some experience in using Ant.

1

Since Ant build files are XML files the document begins with an XML declaration which specifies which version of XML is in use, this is to allow for the possibility of automatic version recognition should it become necessary.

2

The root element of an Ant build file is the project element, it has three attributes.

  • name: The name of the project, it can be any combination of alphanumeric characters that constitute valid XML.

  • default: The default target to use when no target is specified, out of these three attributes default is the only required attribute.

  • basedir: The base directory from which any relative directories used within the Ant build file are referenced from. If this is omitted the parent directory of the build file will be used.

3