ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <>
Subject Re: checking property values
Date Tue, 18 Apr 2006 22:37:06 GMT
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" 
<target name="inputdata">

    <input message="Enter the number of Servers" addproperty="numservers"/>

<target name="checknumservers">
      <condition property="oneserver">
            <equals arg1="${numservers}" arg2="1"/>
     <!-- no standard condition checking greater than, you can write 
custom conditions -->
      <condition property="morethanoneserver">
               <equals arg1="${numservers}" arg2="1"/>

<target name="oneserver" if="oneserver">
<!-- some action here -->

<target name="morethanoneserver" if="morethanoneserver">
<!-- some action here -->


- the third way is to use ant-contrib.



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:
For additional commands, e-mail:

View raw message