How do I create a variable in Ant?
Author: Deron Eriksson
Description: This tutorial shows how to create an Ant variable task to overcome the unchangeable nature of an Ant property
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1

Page:    1 2 >

This tutorial will demonstrate how to create a customized AntSW task in EclipseSW. Rather than a simple 'HelloWorld' task, let's make it more interesting. In Ant, you can't change a property once it has been set. If you try, the new value will be ignored. So, let's write a 'var' task that acts as a variable that we can store and change.

I'll create a new JavaSW Project in Eclipse to hold the new Ant task.

New Java Project

I'll call the project teamcakes-ant-util, with separate source (src) and output (bin) folders.

creating a project called 'teamcakes-ant-util'

I'll add ant.jar to my project's classpathW (as an external jarW) so that I can subclass the Ant Task.

adding ant.jar to project's classpath

The jar file is located in my Eclipse plugins directory. In my version of Eclipse, it is in org.apache.ant_1.6.5\lib.

selecting ant.jar

After adding the ant.jar file, I click Finish.

ant.jar added to build path

(Continued on page 2)

Page:    1 2 >