ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <rambiusparkisan...@yahoo.com>
Subject RE: Problem to set property with refid
Date Thu, 03 Jun 2004 07:23:27 GMT
Hi Vinod,

Let's say the property we want to check is called
testprop. The check can be done in several ways

1) Pure Ant
<target name="main" depends="target_A, target_B"/>

<target name="target_A" if="testprop">
... Do smth here
</target>

<target name="target_B" unless="testprop">
... Do smth here again
</target>

The point is that target "main" will call both
target_A and target_B. Then if testprop IS set
target_A will be excecuted. If testprop IS NOT set
target_B will be executed.

2) Ant + Ant-Contrib
If you have many conditions to check in this way you
may prefer ant-contrib [1] <if> task [2]. In our case:
<target name="main">
    <if>
        <isset property="testprop">
        <then>
            ... Do here the stuff previously done in
target_A
        </then>
        <else>
            ... Do here the stuff previously done in
target_B
        </else>
    </if>
</target>

Note that <isset> is Ant built-in condition. For more
info on condition check [3] and [4].

Regards Ivan

[1]http://ant-contrib.sourceforge.net/
[2]http://ant-contrib.sourceforge.net/tasks/if.html
[3]http://ant.apache.org/manual/CoreTasks/condition.html
[4]http://ant.apache.org/manual/CoreTasks/conditions.html


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.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