Aspectj Cookbook
Recipe 2.9. Building an AspectJ Project Using Ant
Problem
You want to compile an AspectJ project using Ant. Solution
Use the tasks included in the AspectJ toolkit to build your project using Ant. Discussion
The Ant build.xml configuration file in Example 2-6 shows an example for how to call upon the additional AspectJ Ant tasks. Example 2-6. An Ant configuration file that uses the AspectJ tasks
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="compile" name="test"> <property name="src" value="src"/> <property name="build" value="build"/> <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs. properties"> <classpath> <pathelement location="%ASPECTJ_INSTALLATION%/lib/ aspectjtools.jar"/> </classpath> </taskdef> <target name="compile"> <mkdir dir="${build}"/> <iajc destdir="${build}" sourceroots="${src}"> <classpath> <pathelement location="%ASPECTJ_INSTALLATION%/ lib/aspectjrt.jar"/> </classpath> </iajc> </target> </project>
Here is what Example 2-6 does:
See Also
Ant: The Definitive Guide by Jesse Tilly and Eric M. Burke (O'Reilly); the Jakarta Ant online manual at http://jakarta.apache.org/ant/manual/index.html. |