Creating a new Ant build file

To create a new Ant build file for an AspectJ project:

  1. Either from the context menu or from the menu bar's File menu, select New > File.
  2. Call the file build.xml.
  3. Double click on the file to open in the Ant editor.
  4. Edit the file as below:


    <?xml version="1.0" encoding="UTF-8"?>

    <project name="My Project" default="build" basedir=".">

    <target name="init">
      <path id="ajde.classpath">
         <pathelement path="../../plugins/org.eclipse.core.resources_3.2.1.R32x_v20060914.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.osgi_3.2.1.R32x_v20060919.jar"/>
         <pathelement path="../../plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.equinox.registry_3.2.1.R32x_v20060814.jar"/>
         <pathelement path="../../plugins/org.eclipse.equinox.preferences_3.2.1.R32x_v20060717.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
         <pathelement path="../../plugins/org.eclipse.update.configurator_3.2.1.v20092006.jar"/>
         <pathelement path="../../plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.variables_3.1.100.v20060605.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.expressions_3.2.1.r321_v20060721.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar"/>
         <pathelement path="../../plugins/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
         <pathelement path="../../plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar"/>
         <pathelement path="../../plugins/org.aspectj.ajde_1.5.3.200610201049/ajde.jar"/>
         <pathelement path="../../plugins/org.aspectj.weaver_1.5.3.200610201049/aspectjweaver.jar"/>
         <pathelement path="../../plugins/org.aspectj.runtime_1.5.3.200610201049/aspectjrt.jar"/>
      </path>
      <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
         <classpath refid="ajde.classpath" />
      </taskdef>
    </target>

    <target name="build" depends="init">
      <delete dir="${basedir}/bin"/>
      <mkdir dir="${basedir}/bin"/>
      <path id="user.classpath">
         <!-- add additional classpath entries here -->
      </path>
      <!-- read additional ajc options from a file if required -->
      <property name="ajcArgFile" value=""/>
      <!-- fork the compiler -->
      <iajc destDir="${basedir}/bin" failonerror="true" argfiles="${ajcArgFile}"
         verbose="true" fork="true" maxmem="512m">
         <forkclasspath refid="ajde.classpath" />
         <forkclasspath refid="user.classpath" />
         <src path="src/"/>
      </iajc>
    </target>

    </project>

  5. Note: The path to the 'plugins' directory may be different on your machine and you may need to add other paths to the classpath. Update these to reflect the correct values for your environment. You will also need to change the version numbers as appropriate.

Please see the AspectJ language guide for more information on the iajc Ant task.

Related tasks

Creating an Ant build file for an AspectJ plug-in