ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heikki Qvist <heikki.qv...@elisanet.fi>
Subject Re: checking property values
Date Wed, 19 Apr 2006 18:22:09 GMT
If you need to use conditional or plural (i.e.loops) execution, you 
might have a wrong tool.



Antoine Levy-Lambert kirjoitti:
> Hello Leo,
> 
> yes you can.
> 
> you have 3 possibilities :
> 
> - use a combination of Ant and Groovy, so that you script around ant 
> tasks and datatypes, but with the possibility of using all possible 
> procedural logic,
> - the traditional ant way : you need to create special targets which set 
> properties using the condition task. Targets executed after the targets 
> containing the conditions can use the properties in their if attribute
> note that the if and unless attributes of targets are only sensitive to 
> the presence/absence of properties, rather than to their value
> 
> your build looks like this
> 
> <target name="all" 
> depends="inputdata,checknumservers,oneserver,morethanoneserver">
> </target>
> <target name="inputdata">
> 
>    <input message="Enter the number of Servers" addproperty="numservers"/>
> 
> 
> </target>
> <target name="checknumservers">
>      <condition property="oneserver">
>            <equals arg1="${numservers}" arg2="1"/>
>      </condition>
>     <!-- no standard condition checking greater than, you can write 
> custom conditions -->
>      <condition property="morethanoneserver">
>           <not>
>               <equals arg1="${numservers}" arg2="1"/>
>            <not/>
>      </condition>
> 
> </target>
> <target name="oneserver" if="oneserver">
> <!-- some action here -->
> </target>
> 
> <target name="morethanoneserver" if="morethanoneserver">
> <!-- some action here -->
> 
> </target>
> 
> 
> - the third way is to use ant-contrib.
> 
> Regards,
> 
> Antoine
> 
> 
> 
> Leo wrote:
>> Hi,
>>                Iam trying to write a Ant based installer. It basically 
>> will ask for input from the user and then based on that information 
>> does different things. Iam not sure how to check if certain property 
>> is something?      Ex:
>> <input message="Enter the number of Servers" addproperty="numservers"/>
>>   ...
>>   Now I need to do different things depending on the value of 
>> numservers. Like in programming languages, we do:
>>
>>   if (numservers == 1) {
>>   .....
>>   } else if (numservers > 1) {
>>   ....
>>   }
>>      Can we do something similar using Ant?
>>      Thanks!
>>
>>        
>> ---------------------------------
>> Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great 
>> rates starting at 1&cent;/min.
>>   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message