Saturday, August 14, 2010

Macrodef in Ant Script

Very frequently we invoke the same task repeatedly with a small variance. Mostly, we parameterize the variance, then such tasks can be refactored and invoked with different argument repeatedly, just like a Java method call that is invoked with different arguments. Prior to Ant 1.6, the and tasks came in handy. For most part these two core tasks are similar, except the task allows invoking targets in another build file whereas restricted the invoked targets to the local file.
The point to consider is re-parses the build file and re-runs the targets, even though all that changes from one call to another is, in most cases, just the parameter values. Since Ant 1.6 a smarter alternative is available: the task. It offers all the benefits of without the overhead of reparsing. It offers additional features such as ordered execution of nested tasks using the construct. Optional attributes can be supplied with default values, and the caller may omit them. 


Sample Code












For further information  - Ant - Macrodef

No comments:

Post a Comment