# 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" depends="init.variables,init.taskdefs" />
   <target name="init.variables" description="init variables">
   <property name="plugins.dir" location="${basedir}/../../plugins" />
   <property name="aspectjrt.jar" location="${plugins.dir}/org.aspectj.runtime_1.5.0.20050610/aspectjrt.jar" />
   <property name="ajde.jar" location="${plugins.dir}/org.aspectj.ajde_1.5.0.20050610/ajde.jar" />
   </target>
   <target name="init.taskdefs" depends="init.variables" unless="taskdefs.init">
   <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
   <classpath>
   <pathelement path="${ajde.jar}" />
   </classpath>
   </taskdef>
   <property name="taskdefs.init" value="true" />
   </target>
   <target name="build" depends="init" description="build spacewar example">
   <iajc destDir="${basedir}/bin" classpath="${aspectjrt.jar}" fork="true">
   <forkclasspath>
   <pathelement path="${plugins.dir}/org.eclipse.core.boot_3.0.0/boot.jar"/>
   <pathelement path="${plugins.dir}/org.eclipse.core.resources_3.0.2/resources.jar"/>
   <pathelement path="${plugins.dir}/org.eclipse.core.runtime_3.0.2/runtime.jar"/>
   <pathelement path="${plugins.dir}/org.eclipse.core.runtime.compatibility_3.0.2/compatibility.jar"/>
   <pathelement path="${plugins.dir}/org.apache.ant_1.6.2/lib/ant.jar"/>
   <pathelement path="${ajde.jar}" />
   </forkclasspath>
   <srcdir>
   <pathelement path="src/" />
   </srcdir>
   </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. Correct these to reflect the correct values. You may also need to check the version numbers.

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

Using build configurations with Ant
Creating an Ant build file for an AspectJ plug-in