aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT, targets and variable passing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ANT, targets and variable passing" Watch "ANT, targets and variable passing" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ANT, targets and variable passing