I need to write an ant script which has several targets.
The script must be able to differentiate, when invoked,
between two conditions ...call the conditions A or B.
Based on whether condition A or B is specified, the value
of several properties will be set differently. These
properties affect all other targets.
I envision calling the script something like this :
ant A targetX ( or ant B targetY )
Basically, the fact that A was specified would cause
several properties to be uniquely set and their values available
to all other targets.
I am not sure how to accomplish this.
I know I can create two targets ( A and B ) and
set the necessary parameters ..the question is then
how to pickup that second parameter ( targetX ) ...the
specific target I really wanted to execute !
( targetX / targetY in my example above )
Any ideas ?
> I need to write an ant script which has several targets.
>
[quoted text clipped - 22 lines]
>
> Any ideas ?
Well, first of all, ant supports passing multiple targets on the command
line, like make. So if you have targets A, B, targetX, targetY invoking
"ant A targetX" is no problem.
Now this might not be the best way to accomplish what you need. Ant
<target> tags accept unless and if attributes that can cause the target
to be skipped even when explicitly invoked. These may be a help to you.
HTH,
Ray

Signature
XML is the programmer's duct tape.
Rod - 26 Jun 2005 03:32 GMT
Thanks ...that helps.
> > I need to write an ant script which has several targets.
> >
[quoted text clipped - 33 lines]
> HTH,
> Ray
Rod - 30 Jun 2005 14:22 GMT
Thanks for reply ...yes, I know about "depends" ...my situation is that
I need to set the values of several properties based on the "type" of
run being made ( production, local, etc. ) ...additionally, once the
-type- of run is identified, one of several targets may be executed
...yes, I could expect the user to load a particular properties file
..etc, etc. , however, I wanted to keep the ant command as simple as
possible ...hence two targets ...I just wanted to veify that the
caller actually passed in two targets before starting any -real- work.
Currently, I scrapped the two target idea in favor of defining a
property on the ant call ( i.e. ant -Dtarget="DEV" target1 ) and
validating that the property was passed in ...seems though that there
must be a "cleaner" way ....