You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Natalia Bello <nb...@isabel.be> on 2001/09/10 13:58:48 UTC
Set property with condition.
Hi all!
I think it is not difficult, but i dont find the way to do it.
I want to set a property only if two others are not set.
That is, i want to set the property "compile.all" if "include.module" and
"exclude.module" both, are not set.
To what I should compare the properties??
<condition property="compile.all">
<and>
<equals arg1="${include.module}" arg2="??????"/>
<equals arg1="${exclude.module}" arg2="??????"/>
</and>
</condition>
Thanks in advanced!
Natalia
Re: Set property with condition.
Posted by Diane Holt <ho...@yahoo.com>.
--- Natalia Bello <nb...@isabel.be> wrote:
> I think it is not difficult, but i dont find the way to do it.
> I want to set a property only if two others are not set.
> That is, i want to set the property "compile.all" if "include.module"
> and "exclude.module" both, are not set.
> To what I should compare the properties??
I don't think you can use <condition> to check if a property is simply set
(regardless of what it's set to) -- but you could use the if/unless attrs
instead:
<target name="setCompile" depends="chkInc, chkEx" unless="notAll">
<property name="compile.all" value="true"/>
</target>
<target name="chkInc" if="include.module">
<property name="notAll" value="true"/>
</target>
<target name="chkEx" if="exclude.module">
<property name="notAll" value="true"/>
</target>
To use <condition>, you'd need to compare against all the possible module
names -- eg:
<condition property="compile.all">
<not>
<or>
<equals arg1="${include.module}" arg2="foo"/>
<equals arg1="${include.module}" arg2="bar"/>
<equals arg1="${exclude.module}" arg2="foo"/>
<equals arg1="${exclude.module}" arg2="bar"/>
</or>
</not>
</condition>
which could get real ugly real fast.
Diane
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com