Installing Ant Tasks
Prev | Chapter 4. AspectJ Ant Tasks | Next

## Installing Ant Tasks

Install Jakarta Ant 1.5.1: Please see the official Jakarta Ant website for more information and the 1.5.1 distribution. This release is source-compatible with Ant 1.3 and Ant 1.4, but the task sources must be compiled with those versions of the Ant libraries to be used under those versions of Ant. Sources are available under the Eclipse Public License v. 1.0 at http://eclipse.org/aspectj.

In Ant 1.5, third-party tasks can be declared using a taskdef entry in the build script, to identify the name and classes. When declaring a task, include the `aspectjtools.jar` either in the taskdef classpath or in `${ANT_HOME}/lib` where it will be added to the system class path by the ant script. You may specify the task script names directly, or use the "resource" attribute to specify the default names:

      <taskdef
          resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>

The current resource file retains the name "ajc" for the Ajc10 task, and uses "iajc" for the AspectJ post-1.1 task.

In Ant 1.6, third-party tasks are declared in their own namespace using `antlib.xml`. For example, the following script would build and run the spacewar example, if you put the script in the examples directory and `aspectjtools.jar` in the `${ANT_HOME}/lib` directory.

    <project name="aspectj-ant1.6" default="spacewar"
        xmlns:aspectj="antlib:org.aspectj" basedir=".">
        <target name="spacewar">
            <aspectj:iajc
                argfiles="spacewar/debug.lst"
                outjar="spacewar.jar"
                classpath="../../lib/aspectjrt.jar"
           />
           <java classname="spacewar.Game"
            classpath="spacewar.jar:../../lib/aspectjrt.jar"/>
        </target>
    </project>

For more information on using Ant, please refer to Jakarta's documentation on integrating user-defined Ant tasks into builds.

Prev | Up | Next
Chapter 4. AspectJ Ant Tasks | Home | AjcTask (iajc)