| Author |
ANT, targets and variable passing
|
David Edds
Greenhorn
Joined: Dec 06, 2004
Posts: 20
|
|
Hi, I have limited experience of ant, but am wondering if it is possible to pass arguments to a target so the target operates on the supplied values. Note that I am making a distincation using "environment variables". What I wish to do is pass a value to a target and then run the target operating on those values. I guess this is impossible, since I assume that this is not the way ant really works, but I wondered if anyone knew how to do this. The reason I want to do this, is because I have the following scenario: I have a series of tasks to perform in ant. They start off with general tasks, (e.g. cvsCheckout, amalgamate) and then go into a series of tasks for a particular file-set (e.g. compile, junit, coverage, javadoc). I need to repeat that set of tasks for different file sets. Once I have done that I do a couple more general tasks (e.g. clean-up, publish) and I'm done. I can achieve the above by writing the following targets in my ant script: cvsCheckout amalgamate compileSet1 junitSet1 coverageSet1 ... compileSet2 junitSet2 coverageSet2 ... compileSet3 junitSet3 coverageSet3 ... publish But surely there is a way to do this without all of the repetition? The targets compileSet1 and compileSet2 are very similar, they just work on different filesets and different file locations. Any help or advice is greatly appreciated, David
|
 |
madhu yadav
Greenhorn
Joined: Apr 27, 2003
Posts: 3
|
|
Hi, You can use macros as an alternative to these targets. As u said except the filesets these targets are similar, u can pass these as parameters to the macro. Please refer to the ant 1.6.2 manual for further reference.
|
 |
David Edds
Greenhorn
Joined: Dec 06, 2004
Posts: 20
|
|
Thanks Madhu, That is the sort of thing I need. I have tried it out and it works well. Thanks again, David
|
 |
 |
|
|
subject: ANT, targets and variable passing
|
|
|