blob: d4b0e182991ec2bf1c491457b3fc9cc305dd771f [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<title>Using a different version of Ant</title>
<meta name="keyword" content="ant">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Using a different version of Ant</H1>
<P> The Eclipse platform provides Ant 1.5.2 as a plug-in library. When running
an Ant buildfile in the Workbench, version 1.5.2 is used by default. It is possible
to use different versions, although they are not supported. There are at least
two ways of using a different version of Ant:
</P>
<dl>
<dt><b>Changing the Ant runtime classpath:</b></dt>
<dd>When Ant runs a buildfile, it looks for the necessary classes on the Ant classpath.
The Ant classpath consists of the plug-ins contributing new tasks, types or
libraries, plus the classpath defined in the Ant runtime classpath preferences. To
access the preferences, click <b>Window > Preferences > Ant > Runtime</b>.
The two JARs related to Ant 1.5.2 are <code>ant.jar</code> and <code>optional.jar</code>.
Remove these JARs and add the ones from the desired Ant version.
<p>Note that explicitly adding the Xerces
JARs to the runtime Ant classpath is no longer required and will cause problems. The Xerces
classes are loaded from the org.apache.xerces plug-in provided with Eclipse. For most Ant
distributions, the Xerces JARs cannot even be in the same physical location as the ant.jar
and optional.jar. This results from the Ant JARs containing manifest files which contain
classpath entries pointing to the Xerces JARs.
<p>After you change the Ant classpath, all future Ant builds will use the updated
version instead of the default. To restore the Ant classpath to its original
state, <b>Restore Defaults</b> button on the preference page.
</p>
</dd>
<dt><b>Using Ant as an external tool:</b></dt>
<dd>When changing the Ant classpath is not an option, or if you just want to test
a newer version or beta version of Ant, using it as an external tool can be
a better solution. Usually when it is running in the Workbench, the Ant buildfile
itself is considered to be a external tool, but this is not the only way.
To install a binary distribution of Ant as an external tool (<b>Note:</b>
These steps are for Windows, but similar methods can be used for other operating systems):
<ol type="a">
<li>Download and install the binary version of Ant from
<a href="http://ant.apache.org" target="_blank">http://ant.apache.org</a> .</li>
<li>Click <b>Run &gt; External Tools &gt; External Tools...</b>.</li>
<li>Click <b>Program</b></li>
<li>Click <b>New</b>.</li>
<li>Enter a name for your external tool (for example, External Ant).</li>
<li>For the <b>Location</b> field, click <b>Browse File System</b>.</li>
<li>Find and select a file called <code>ant.bat</code> (it should be
in the <code>bin</code> folder of your Ant installation).</li>
<li>In the <b>Arguments</b> field enter the arguments for your
buildfile that would normally enter for running the buildfile outside of the
Workbench.</li>
<li>In the <b>Working Directory</b> field enter the directory of your buildfile.</li>
<li>Click <b>Run</b> to execute the buildfile.</li>
</ol>
<p>When you run Ant as an external tool, none of the tasks or types
contributed by Eclipse will work. Also, the Ant classpath preference has no
effect in the buildfile execution.
</p>
</dd>
</dl>
<p><img border="0" src="../images/ngrelc.gif" alt="Related concepts" width="159" height="27"><br>
<a href="../concepts/concepts-antsupport.htm">Ant Support</a><br>
<a href="../concepts/concepts-exttools.htm">External tools</a>
</p>
<p><img border="0" src="../images/ngrelt.gif" alt="Related tasks" width="159" height="27"><br>
<a href="./tasks-ant-running.htm">Running Ant buildfiles</a><br>
<a href="../tasks/tasks-exttools-running.htm">Running external tools</a><br>
<a href="../tasks/tasks-ant-classpath.htm">Modifying the Ant classpath</a><br>
<a href="../tasks/tasks-ant-addtasksandtypes.htm">Adding new Ant tasks and types</a><br>
</p>
<p>&nbsp;<br>
<a href="../hglegal2003.htm">
<img src = "../images/ngibmcpy2003.gif" alt="Copyright IBM Corporation and others 2000, 2003" border="0" width="324" height="14"></a>
</p>
</BODY>
</HTML>