ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Rodriguez <>
Subject RE: setting a property based on a condition
Date Thu, 23 Aug 2001 20:01:29 GMT
Thank you, it worked perfectly.

-----Original Message-----
From: Diane Holt []
Sent: Thursday, August 23, 2001 12:42 PM
Subject: Re: setting a property based on a condition

With 1.4, you could use the new <condition> task:

  <target name="setProp">
    <condition property="num" value="1">
      <equals arg1="${foo}" arg2="true"/>
    <condition property="num" value="2">
      <equals arg1="${foo}" arg2="false"/>
    <echo message="num is ${num}"/>

(In pre-1.4, you'd need to use the <script> task.)


--- Anthony Rodriguez <> wrote:
> Quick question:
> Is there any way to set a property in ant based on a condition? For
> example,
> say I have a boolean property named "foo".  Now I want to set a property
> named "num" to 1 if foo is true or set num to 2 if foo is false.  Here
> is
> some pseudo ant to better explain my question:
> pseudobuild.xml:
> ...
> <target name="init">
> 	<property name="foo" value="true"/>
> 	<property name="num"  if ${foo} value="1" else value="2"/>
> </target>
> ...
> Any way to do this in ant?  Thanks for any help.
> -Anthony


Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger

View raw message