Reputation: 678
I have a Ant build.xml that does a check as below, i was just wondering what the $$ signifies?
Thanks in advance for your help.
<equals casesensitive="false" arg1="${subPlan}" arg2="$${subPlan}"/>
Upvotes: 0
Views: 196
Reputation: 10377
From ant manual Properties and PropertyHelpers :
..Ant will expand the text $$ to a single $ and suppress the normal property expansion mechanism..
It's often used for output like that :
<property name="foo" value="bar"/>
<echo>$${foo} => ${foo}</echo>
output :
[echo] ${foo} => bar
In your case it checks whether a property with the name subPlan is set within your project, as ${subPlan} won't be expanded if it doesn't exist, f.e. :
<project>
<property name="subPlan" value="whatever"/>
<echo>${subPlan}</echo>
</project>
output :
[echo] whatever
whereas :
<project>
<echo>${subPlan}</echo>
</project>
output :
[echo] ${subPlan}
It's actually possible to set the propertyvalue for Property subPlan to ${subPlan} :
<property name="subPlan" value="$${subPlan}"/>
but that doesn't make sense, so your snippet does a combined check => is Property subPlan set and has a useful value ? could be used like that :
<fail message="Property not set or invalid value !">
<condition>
<equals casesensitive="false" arg1="${subPlan}" arg2="$${subPlan}"/>
</condition>
</fail>
Finally the standard way to check whether a property is set is using the isset condition, f.e. :
<fail message="Property not set !">
<condition>
<not>
<isset property="subPlan"/>
</not>
</condition>
</fail>
Upvotes: 3