This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
Joined: Dec 06, 2004
That is the sort of thing I need. I have tried it out and it works well.