ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Kelem <>
Subject Ant design & use question: conditional flows in Ant
Date Tue, 04 Nov 2003 06:04:34 GMT
I have two possible build flows, depending on what my real-life target 
is (waba or j2me).
I thought it would be easy to set a parameter at the top of my build.xml 
file, and then use if= on my target tasks
to indicate which task should be executed.  However, ant doesn't allow 
two different tasks with the same name.

Flow I is:

init, compileI, test, deployI

Flow II is

init, compileII, preverify, test, deployII

Using the roundabout way of setting properties, I had
<condition property="flowI" value="true"/>
 <istrue value="true"/>
<condition property="flowII" value="true"/>
 <istrue value="false"/>

<target name="compile" if="compileI"/>
 <javac with compileI params.../>
<target name="compile" if="compileII"/>
 <javac with compileII params.../>

I was hoping that, by having mutually exclusive "if"s (which, I realize 
can't be checked in advance by ant),
that the appropriate target would be chosen.

My questions:
1. If I have two flows, how do I reconcile both with having a common 
end-goal, namely "all"?  I can't have "all" depend on "deployI" and 
"deployII", because I will not be exercising both flows for a given 
execution of ant.
Is there a way to disable some of the tasks (e.g., flow I) and let Flow 
II run, then, on another run of ant, disable the other tasks (e.g., flow 
II), and let flow I run?  Or, do I need to have separate end targets, 
i.e., "all-I" and "all-II", in which case the conditional "if"s aren't 
needed at all.

2. How is the "if" attribute of the "task" useful?  The task executes if 
some property is set, but what happens if the parameter is not set?  
Does the whole flow just come to a stop? In what situations is that useful?

Thans for your help,
Steve Kelem

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message