Version @build.version.long@ released on @build.date@.
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 Common Public License v. 1.0 at http://eclipse.org/aspectj.
In Ant, 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, using "iajc" for the AspectJ 1.1 task. This may change in the final release of AspectJ 1.1.
For more information on using Ant, please refer to Jakarta's documentation on integrating user-defined Ant tasks into builds.
Following is a declaration for the ajc task and a sample invocation that uses the ajc compiler to compile the files listed in default.lst into the dest dir.
<project name="example" default="compile" > <taskdef name="ajc" classname="org.aspectj.tools.ant.taskdefs.Ajc10" > <!-- declare classes needed to run the tasks and tools --> <classpath> <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/> </classpath> </taskdef> <target name="compile" > <mkdir dir="dest" /> <ajc destdir="dest" argfiles="default.lst" > <!-- declare classes needed to compile the target files --> <classpath> <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/> </classpath> </ajc> </target> </project>
Below is an example of incrementally compiling src and testsrc root source directories, using tagfile.txt to control recompilation and halting. When this script is run, the compiler will build once and then wait for incremental builds, recompiling each time the last-modified date changes on the tag file. When the tag file no longer exists, the build will complete. Messages are printed as usual.
<project name="incremental-example" default="compile" > <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"> <classpath> <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/> </classpath> </taskdef> <target name="compile" > <mkdir dir="dest" /> <inc-ajc destdir="dest" tagfile="tagfile.txt" sourceroots="src${path.separator}testsrc" > <!-- declare classes needed to compile the target files --> <classpath> <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/> </classpath> </inc-ajc> </target> </project>
build.compiler
property to the class name. This enables users to
to easily switch between Javac and the AspectJ compiler.
To build this way, install aspectjtools.jar in ${ANT_HOME}/lib
and define the build.compiler
property as the fully-qualified name of the class:
cp aspectj1.1/lib/aspectjtools.jar ant/lib ant/bin/ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter ...The AspectJ compiler should run for any compile using the Javac task (for options, see the Ant documentation for the Javac task).
To pass ajc-specific arguments, use a compilerarg
entry.
For example,
-- command Ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11BuildCompiler -- build script <property name="ajc" value="org.aspectj.tools.ant.taskdefs.Ajc11BuildCompiler"/> <javac srcdir="src" destdir="dest" > <compilerarg compiler="$${ajc}" line="-argfile src/args.lst"/> <javac >Beware of using regular source lists with this; javac may prune unchanged files, which excludes them from the compile process for ajc, which requires that all files affected by any aspects be listed explicitly.
If you have problems with the tasks not solved by the documentation, please try to see if you have the same problems when running ajc directly on the command line.
Known Problems
For the most up-to-date information on known problems, see the
bug database.
You can send email to
mailto:aspectj-users@dev.eclipse.org.
(Do join the list to participate!) We also welcome any bug reports; you can
submit them to the bug database at
http://dev.eclipse.org
using the AspectJ
product and Ant
component.