Using a different version of Ant

The Eclipse platform provides Ant 1.4.1 as a plug-in library. When running an Ant script in the Workbench, version 1.4.1 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 script, 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 > External Tools > Ant. The two JARs related to Ant 1.4.1 are ant.jar and jakarta-ant-1.4.1-optional.jar. Remove these JARs and add the ones from the desired Ant version.

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):
  1. Download and install the binary version of Ant from http://jakarta.apache.org/ant .
  2. Click Run > External Tools > Configure.
  3. Click New.
  4. Enter a name for your external tool (for example, External Ant).
  5. Click Browse File System.
  6. Find and select a file called ant.bat (it should be in the bin folder of your Ant installation).
  7. In the Tool Arguments field enter the arguments for your script that would normally enter for running the script outside of the Workbench.
  8. In the Working directory field enter the directory of your script.
  9. Click OK to exit the wizard.
  10. To run the script, click Run > External Tools > External Ant.

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.

Related concepts
Ant Support
External tools

Related tasks
Running Ant build files
Running external tools
Modifying the Ant classpath
Adding new Ant tasks and types

 
Copyright IBM Corporation and others 2000, 2002