Version 1.0.6 released on July 24, 2002.
This package contains Ant tasks for the AspectJ compiler (ajc) and for the AspectJ documentation tool (ajdoc).
lib/aspectj-ant.jar: task class files
doc/ajc-ant-task.html: ajc taskdef usage documentation
doc/ajdoc-ant-task.html: ajdoc taskdef usage documentation
doc/taskdefs-api: API documentation
src/: Taskdef source files
These releases do not yet support some of the options available in the underlying tools or in similar tasks from Apache, but they have been used successfully by a number of people. (The sources are provided with the release so you can fix bugs yourself if you are that sort of person.) Please email us ( support@aspectj.org) if you have any comments, bugs, or fixes.
In Ant, third-party tasks must be declared using taskdefs in the build script, to identify the name and classes. When you declare these tasks, include classes for both the tasks and the AspectJ tools they use (ajc and ajdoc) in the classpath. The tool classes are in aspectjtools.jar. You will also have to include the aspectjrt.jar in the user class path when you invoke the task in order to compile.
Defining and using the task
Like any task not built-in to Ant, these must be declared in your build script. You can set the classpath for the task at the same time to include aspectj-ant.jar and aspectj-tools.jar, or you can install the libraries in ${ant.home}/lib. Following is a declaration for the ajc taskdef and a sample invocation that uses the ajc compiler via the ajc taskdef 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.Ajc" > <!-- declare classes needed to run the tasks and tools --> <classpath> <pathelement location="${home.dir}/tools/aspectj/lib/aspectj-ant.jar"/> <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/> <pathelement location="${home.dir}/tools/jdk13/lib/tools.jar"/> </classpath> </taskdef> <target name="compile" > <mkdir dir="dest" /> <ajc workingdir="temp" 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>
The declaration would be similar for the ajdoc task, except to use the class name org.aspectj.tools.ant.taskdefs.Ajdoc.
Classpath AlternativesIf for some reason you do not want to include the libraries in the taskdef, you have to set up the classpath accordingly. The Ant distribution includes scripts that add library jars to its classpath. If you use these scripts, then you can put aspectj-ant.jar and aspectjtools.jar in the {ANT_HOME}/lib directory, where it will be added to the class path by the ant script. For example, if Ant is installed in /home/user/tools/ant then put aspectj-ant.jar and aspectj-tools.jar in /home/user/tools/ant/lib. (However, for invoking ajdoc you must include a tools.jar from J2SE 1.3 on the classpath, which may conflict with users of tools.jar expecting another version. In this case it is usually better to use the ant taskdef entry to define the task classpath.) If you are otherwise invoking Ant, make sure the classes are on the classpath when you run Ant.
If you have problems with the tasks not solved by the documentation, please try to see if you have the same problems when running the ajc or ajdoc tools directly on the command line.
Known Problems
For the most up-to-date information on known problems, see the
bug database for
compiler bugs,
ajdoc bugs,
or taskdef bugs.
ajc tool
You can send email to users@aspectj.org. (Do join the list to participate!) We also welcome any bug reports; you can submit them to http://aspectj.org/bugs.