blob: 1889bbc6abdd1a67ade8744129ad25cc139bd78c [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Creating a new Ant build file
</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
</head>
<body>
<h1>
Creating a new Ant build file
</h1>
<p>
To create a new Ant build file for an AspectJ project:
</p>
<ol>
<li>
Either from the context menu or from the menu bar's <strong>File</strong> menu, select <strong>New &gt; File</strong>.
</li>
<li>
Call the file <em>build.xml</em>.
</li>
<li>
Double click on the file to open in the Ant editor.
</li>
<li>
Edit the file as below:
<p><code><br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br><br>
&lt;project name="My Project" default="build" basedir="."&gt;<br><br>
&nbsp;&nbsp; &lt;target name="init" depends="init.variables,init.taskdefs" /&gt; <br><br>
&nbsp;&nbsp; &lt;target name="init.variables" description="init variables"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="plugins.dir" location="${basedir}/../../plugins" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="aspectjrt.jar" location="${plugins.dir}/org.aspectj.runtime_1.5.0.20050610/aspectjrt.jar" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="aspectjweaver.jar" location="${plugins.dir}/org.aspectj.weaver_1.5.0.20050610/aspectjweaver.jar" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="ajde.jar" location="${plugins.dir}/org.aspectj.ajde_1.5.0.20050610/ajde.jar" /&gt; <br>
&nbsp;&nbsp; &lt;/target&gt;<br><br>
&nbsp;&nbsp; &lt;target name="init.taskdefs" depends="init.variables" unless="taskdefs.init"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;classpath&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${ajde.jar}" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/classpath&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/taskdef&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="taskdefs.init" value="true" /&gt; <br>
&nbsp;&nbsp; &lt;/target&gt;<br><br>
&nbsp;&nbsp; &lt;target name="build" depends="init" description="build spacewar example"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;iajc destDir="${basedir}/bin" classpath="${aspectjrt.jar}" fork="true"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;forkclasspath&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${plugins.dir}/org.eclipse.core.boot_3.1.0/boot.jar"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${plugins.dir}/org.eclipse.core.resources_3.1.0/resources.jar"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${plugins.dir}/org.eclipse.core.runtime_3.1.1/runtime.jar"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${plugins.dir}/org.eclipse.core.runtime.compatibility_3.1.0/compatibility.jar"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${plugins.dir}/org.apache.ant_1.6.5/lib/ant.jar"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${ajde.jar}" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="${aspectjweaver.jar}" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/forkclasspath&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;srcdir&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pathelement path="src/" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/srcdir&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/iajc&gt;<br>
&nbsp;&nbsp; &lt;/target&gt;<br><br>
&lt;/project&gt; <br><br>
</code>
</p>
</li>
<li>
<strong>Note: </strong>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 will also need to change the version numbers as appropriate.
</li>
</ol>
<p>
Please see the AspectJ language guide for more information on the iajc Ant task.
</p>
<p>
<img src="../images/ngrelt.gif" alt="Related tasks" border="0" height="27" width="159">
</p>
<p>
<a href="buildconfigsandant.htm">Using build configurations with Ant</a><br>
<a href="newpluginbuildfile.htm">Creating an Ant build file for an AspectJ plug-in</a>
</p>
<p>
<a href="../notices.html"><img src="../cpy.gif" border="0" alt="Legal notices" width="324" height="14"></a>
</p>
</body>
</html>