Reputation: 117
Here's what the manual says about "condition":
Sets a property if a certain condition holds true. If the condition holds true, the property value is set to true by default; otherwise, the property is not set. You can set the value to something other than the default by specifying the value attribute
What I try:
<echo message="${a}" />
<condition property="a">
<isfalse value="test" />
</condition>
<echo message="${a}" />
My reasoning:
if property "a" isfalse then set the value of "a" to "test"
The result that is echoed is:
[echo] ${a}
[echo] true
The property is set to "true" because it was false, but what is the purpose of "value" then?
thank you
Chris
Upvotes: 0
Views: 555
Reputation: 122364
Ant properties are immutable - once set they cannot be changed. So you can't modify the value of "a" but you could set a different property conditionally. For the following slight modification of your problem statement:
if property "a" is false then set the value of b to "test"
you could use
<condition property="b" value="test">
<isfalse value="${a}"/>
</condition>
The condition
tag's property attribute is the property you're setting, and its value attribute is the value to set it to if the condition succeeds. The value you're testing is the value attribute on the isfalse
.
Upvotes: 5