Ant Script Library Usage


The ASL needs to be accessible from the client project. You can put the ASL in a subdirectory, sibling directory of the project, or in a well known location on an internal network. In the examples on this page, the ASL is assumed to be in a subdirectory. If you have installed the somewhere different, you will need to adjust the file path in the import file attribute.

To install the scripts, you can do one of the following:

Simple Example

This is the simplest build.xml that makes use of the ASL:

<project name="hello-world" default="dist">
    <import file="ant-script-library/asl-java.xml"/>

This script would be suitable for a Java project that had a directory structure similar to the standard directory layout.

Overriding Properties

Not all projects will exactly match the default configuration of the ASL. In many cases, simply overriding a property will suffice. For example, if the project source code is found in the directory src (instead of the expected directory src/main/java), then the following build.xml would work:

<project name="hello-world" default="dist">
    <property name="java-build.src-dir" location="src"/>
    <import file="../ant-script-library/asl-java.xml"/>

This is a common idiom within ASL - default values of properties can be overridden by defining them before importing the ASL scripts. This works because properties in Ant are immutable: whoever sets a property first freezes it for the rest of the build. Refer to the documentation of the Property Task for more information.

For the complete set of properties that can be controlled in this way, look to the reference, or refer to the scripts themselves.

Overriding Targets


Is there a problem or mistake on this page? Do you want to contribute some changes? Send me an email at