Using a different version of Ant
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:
- Changing the Ant classpath:
- 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 external tools preferences. To
access the preferences, click Window > Preferences > Ant > Runtime.
The two JARs related to Ant 1.5.2 are
ant.jar
and optional.jar
.
Remove these JARs and add the ones from the desired Ant version.
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.
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, Restore Defaults button on the properties page.
- Using Ant as an external tool:
- 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 script
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 (Note:
These steps are for Windows, but similar methods can be used for other operating systems):
- Download and install the binary version of Ant from
http://ant.apache.org .
- Click Run > External Tools > External Tools....
- Click Program
- Click New.
- Enter a name for your external tool (for example, External Ant).
- For the Location field, click Browse File System.
- Find and select a file called
ant.bat
(it should be
in the bin
folder of your Ant installation).
- In the Arguments field enter the arguments for your
script that would normally enter for running the script outside of the
Workbench.
- In the Working Directory field enter the directory of your buildfile.
- Click Run to execute the buildfile.
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 script execution.

Ant Support
External tools

Running Ant buildfiles
Running external tools
Modifying the Ant classpath
Adding new Ant tasks and types