Ajc10 (ajc)

This task handles the same arguments as those used by the AspectJ 1.0 task. This should permit those with existing build scripts using the Ajc Ant task to continue using the same scripts when compiling with 1.1. This will list any use of options no longer supported in 1.1 (e.g., lenient, strict, workingdir, preprocess, usejavac,...), and does not provide access to the new features of AspectJ 1.1. (Developers using AspectJ 1.1 only should upgrade their scripts to use AjcTask instead. This will not work for AspectJ 1.2 or later.)

Ajc10 (ajc) Options

Most attributes and nested elements are optional. The compiler requires that the same version of aspectjrt.jar be specified on the classpath, and that some sources be be specified (using one or more of argfiles and srcdir (with patterns)).

Boolean parameters default to false unless otherwise stated.

Table 4.1. AjcTask (ajc) options for specifying sources



The base directory of the java files. See


The target directory for the output .class files


Comma-separated list of patterns of files that must be included. No files are included when omitted.


The path to a file containing include patterns.


Comma-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted.


The path to a file containing exclude patterns.


If true, then default excludes are used. Default excludes are used when omitted (i.e., defaults to true).

classpath, classpathref

The classpath to use, optionally given as a reference to a classpath Path element defined elsewhere.

bootclasspath, bootclasspathref

The bootclasspath to use, optionally given as a reference to a bootclasspath Path element defined elsewhere.


Paths to directories containting installed extensions.


If true, emit debug info in the .class files.


If true, emit messages about use of deprecated API.


Emit compiler status messages during the compile.


Emit version information and quit.


If true, throw BuildException to halt build if there are any compiler errors. If false, continue notwithstanding compile errors. Defaults to true.


Value of -source option - ignored unless 1.4.

Table 4.2. Parameters ignored by the old ajc taskdef, but now supported or buggy



Default encoding of source files.



Whether source should be compiled with optimization.



Generate class files for specific VM version, one of [1.1 1.2].



Enables dependency-tracking.



Whether to include the Ant run-time libraries.



Whether to include the run-time libraries from the executing VM.



Multi-threaded compilation


The following table shows that many of the unique parameters in AspectJ 1.0 are no longer supported.

Table 4.3. Parameters unique to ajc



deprecated X options include reweavable (on by default) reweavable:compress (compressed by default)


Generate symbols for Emacs IDE support.


A comma-delimited list of argfiles that contain a line-delimited list of source file paths (absolute or relative to the argfile).

argfiles - argument list files

An argument file is a file (usually {file}.lst) containing a list of source file paths (absolute or relative to the argfile). You can use it to specify all source files to be compiled, which ajc requires to avoid searching every possible source file in the source path when building aspects. If you specify an argfile to the ajc task, it will not include all files in any specified source directory (which is the default behavior for the Javac task when no includes are specified). Conversely, if you specify excludes, they will be removed from the list of files compiled even if they were specified in an argument file.

The compiler also accepts arguments that are not source files, but the IDE support for such files varies, and Javac does not support them. Be sure to include exactly one argument on each line.

Ajc10 parameters specified as nested elements

This task forms an implicit FileSet and supports all attributes of <fileset> (dir becomes srcdir) as well as the nested <include>, <exclude>, and <patternset> elements. These can be used to specify source files.

ajc's srcdir, classpath, bootclasspath, extdirs, and jvmarg attributes are path-like structures and can also be set via nested <src>, <classpath>, <bootclasspath>, <extdirs>, and <jvmargs> elements, respectively.

Sample of ajc task

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 -->
      <pathelement location="${home.dir}/tools/aspectj/lib/aspectjtools.jar"/>

  <target name="compile" >
    <mkdir dir="dest" />
    <ajc destdir="dest" argfiles="default.lst" >
      <!-- declare classes needed to compile the target files -->
        <pathelement location="${home.dir}/tools/aspectj/lib/aspectjrt.jar"/>


This build script snippet

		  <ajc srcdir="${src}"


compiles all .java files specified in the demo.lst and stores the .class files in the ${build} directory. Unlike the Javac task, the includes attribute is empty by default, so only those files specified in demo.lst are included.

This next example

		  <ajc srcdir="${src}"


compiles .java files under the ${src} directory in the spacewar and coordination packages, and stores the .class files in the ${build} directory. All source files under spacewar/ and coordination/ are used, except Debug.java.

See ../examples/build.xml for an example build script.