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
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. I'll call the project teamcakes-ant-util, with separate source (src) and output (bin) folders. I'll add ant.jar to my project's classpathW (as an external jarW) so that I can subclass the Ant Task. 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. After adding the ant.jar file, I click Finish. (Continued on page 2) |