You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Pellier, Marc" <Ma...@atosorigin.com> on 2003/02/17 15:05:38 UTC

if then else with ant

How can I do 

if (a=2)
	print("Message1");
else
	print("Message2");


with ANT

****************************************************************************
Disclaimer: 
This electronic transmission and any files attached to it are strictly 
confidential and intended solely for the addressee. If you are not 
the intended addressee, you must not disclose, copy or take any
action in reliance of this transmission. If you have received this 
transmission in error, please notify the sender by return and delete
the transmission.  Although the sender endeavors to maintain a
computer virus free network, the sender does not warrant that this
transmission is virus-free and will not be liable for any damages 
resulting from any virus transmitted. 
Thank You.
****************************************************************************


Re: if then else with ant

Posted by Antoine Levy-Lambert <le...@tiscali-dsl.de>.
possible answer :
<!-- sets the property message to Message 1 if a=2 -->
<condition property="message" value="Message 1">
   <equals arg1="${a} arg2="2"/>
 </condition>
<!-- properties are unmutable, so this will only be done if the precedent
setting was not done -->
<property="message" value="Message 2"/>
<!-- show the contents of message -->
<echo message="${message}"/>

----- Original Message -----
From: "Pellier, Marc" <Ma...@atosorigin.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Monday, February 17, 2003 3:05 PM
Subject: if then else with ant


How can I do

if (a=2)
print("Message1");
else
print("Message2");


with ANT

****************************************************************************
Disclaimer:
This electronic transmission and any files attached to it are strictly
confidential and intended solely for the addressee. If you are not
the intended addressee, you must not disclose, copy or take any
action in reliance of this transmission. If you have received this
transmission in error, please notify the sender by return and delete
the transmission.  Although the sender endeavors to maintain a
computer virus free network, the sender does not warrant that this
transmission is virus-free and will not be liable for any damages
resulting from any virus transmitted.
Thank You.
****************************************************************************


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



Re: if then else with ant

Posted by Dale Anson <da...@germane-software.com>.
You can also use the "if" task that comes with the Antelope distribution:

<if name="a" value="2">
    <echo>Message1</echo>
    <else>
        <echo>Message2</echo>
    </else>
</if>

Antelope home page is http://antelope.sourceforge.net.
"if" task documentation is at 
http://antelope.sourceforge.net/manual/bk03ch05.html.

Dale Anson
danson@germane-software.com


Pellier, Marc wrote:

>How can I do 
>
>if (a=2)
>	print("Message1");
>else
>	print("Message2");
>
>
>with ANT
>
>****************************************************************************
>Disclaimer: 
>This electronic transmission and any files attached to it are strictly 
>confidential and intended solely for the addressee. If you are not 
>the intended addressee, you must not disclose, copy or take any
>action in reliance of this transmission. If you have received this 
>transmission in error, please notify the sender by return and delete
>the transmission.  Although the sender endeavors to maintain a
>computer virus free network, the sender does not warrant that this
>transmission is virus-free and will not be liable for any damages 
>resulting from any virus transmitted. 
>Thank You.
>****************************************************************************
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>


Re: if then else with ant

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 17 Feb 2003, Marc Pellier <Ma...@atosorigin.com> wrote:
> How can I do 
> 
> if (a=2)
> 	print("Message1");
> else
> 	print("Message2");

<condition property="message" value="Message1">
  <equals arg1="${a}" arg2="2"/>
</condition>
<property name="message" value="Message2"/>
<echo>${message}</echo>

Stefan