Chapter 8. Working with Apache Ant Builds

8.1. Installing Apache Ant for Hudson

The general configuration for Apache Ant installs on Hudson is available in Section 3.4, “Configuring Ant Installations”. You can read about influencing factors for your Apache Maven install, that apply to your strategy for installing Ant as well in Section 7.1, “Installing and Configuring Apache Maven”.

A common scenario for Apache Ant installs is the requirement of a build to have access to Ant tasks as provided in Ant-Contrib like For or If or to have some required libraries like JSch for secure copying with scp available on the Ant class-path. Custom developed Ant tasks can be needed in a similar fashion. A convenient way to achieve this, is the creation of a custom archive containing the Ant install as well as additional libraries necessary. This archive can then be used with the Extract from *.zip/*.tar.gz option to get a fully working Ant and dependencies installed on all build cluster nodes.

8.2. Configuring Apache Ant Builds

After configuring the general project options as documented in Chapter 6, Creating Hudson Projects, you can configure one or more build steps. To add a build step, click on the Add build step button and select Invoke Ant.

The basic and advanced options for invoking Ant are shown in Figure 8.1, “Configuring an Ant Build Steps”.

Figure 8.1. Configuring an Ant Build Steps


Ant Version
Your Hudson installation may have one or more Ant installations configured as part of the global Hudson configuration. This drop-down allows you to specify the version of Ant for usage with the current build step.
This field allows you to specify the command-line parameters used for the Ant invocation. These are all options and targets supported by the specified Ant and the current Build File. If nothing is specified in this field, the build step will invoke Ant without parameters. With a default target specified in the build file, this can be sufficient for a full build depending on your build file.
Build File
If your project uses the standard build.xml file-name, there is no need to specify a Build File If your project uses a build file with an alternative name or path other than directly in the project root, you can specify that file name and path here. This setting is equivalent to the command line option -f buildfilepath. The path specified has to be relative to the project root.
You can pass one or more properties to the Ant process. This field accepts a list of properties with lines in a key=value format. These properties will be passed into the Ant build step invocation using the standard way of passing properties of -Dkey1=value1 -Dkey2=value2.
Java Options
If your build requires specific Java options, they can be set in this field. The options are passed straight through as ANT_OPTS and use the normal java command-line options syntax. A common configuration for complex builds is to specify a larger memory for the JVM running Ant via -Xmx1024m.