Ant targets

R

Rod

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 ?
 
R

Raymond DeCampo

Rod said:
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 ?

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
 
R

Rod

Thanks ...that helps.

Raymond said:
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
 
R

Rod

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 ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ANT Parameters 1
ant inheritance 2
custom targets and eclipse 0
Some questions on Ant 28
Loop in Ant? 2
ant script, problem with classpath 4
Codelite 0
symbolic links cannot be preserved by ant tar 1

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top