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:
- Download and unzip the script files
- Check out the files directly from the Subversion repository:
(note that the SSL certificate on www.exubero.com is currently self-signed, meaning that you will probably be prompted about an invalid certificate. You will have to add an exception)
svn co https://www.exubero.com/asl/svn/trunk/ ant-script-library
This is the simplest
build.xml that makes use of the
<project name="hello-world" default="dist"> <import file="ant-script-library/asl-java.xml"/> </project>
This script would be suitable for a Java project that had a directory structure similar to the standard directory layout.
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
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"/> </project>
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.
Is there a problem or mistake on this page? Do you want to contribute some changes? Send me an email at firstname.lastname@example.org.