ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject RE: Conditional Statement
Date Wed, 30 Jul 2003 21:32:48 GMT
> 
> <target name="init">
> 			
> 	<property name="var1" value="Vik"/>
> 	<property name="var2" value="Vik"/>
> 	<property name="var3" value="Viky"/>
> </target>
> <target name="suzCvsTest" description="Test"
> depends="init">
> 	
> 	<condition property="test">
> 	<equals arg1="${var1}" arg2="${var3}"/>
> 	</condition>
> </target>
> 
> <target name="suzCvsTest1" if="test"
> description="Test"
> depends="suzCvsTest">
> 	
> 	<echo message="Values are equal=${test}"/>
>       
> </target>
> 
> 
> Now since var1 is not equal to var3 the
> target=suzCvsTest1 wasn't
> executed. In the books and manual the "if" attribute
> in the <target> is
> defined as "if the given property has been defined
> the target will be
> executed".

Yep, if the property has been defined... but to do an
either/or:

<target name="init">
	<property name="var1" value="Vik"/>
	<property name="var2" value="Vik"/>
	<property name="var3" value="Viky"/>
</target>
<target name="suzCvsTest" description="Test"
depends="init">
	<condition property="test">
		<equals arg1="${var1}" arg2="${var3}"/>
	</condition>
</target>

<target name="resultno" unless="test">
	<echo message="Values are not equal=${test}"/>
</target>

<target name="resultyes" if="test">
	<echo message="Values are equal=${test}"/>
</target>

<target name="suzCvsTest1" description="Test"
depends="suzCvsTest,resultno,resultyes" />

Kind of big for the amount of work actually being done
in this contrived example, but you get the general
idea.

-Matt

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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


Mime
View raw message