我有一个Ant build.xml,它进行如下检查,我只是想知道$$意味着什么?
提前谢谢你的帮助。
<equals casesensitive="false" arg1="${subPlan}" arg2="$${subPlan}"/>发布于 2014-03-13 20:02:04
来自ant手册性质与PropertyHelpers:
..Ant will expand the text $$ to a single $ and suppress the normal property expansion mechanism..它经常用于输出,如:
<property name="foo" value="bar"/>
<echo>$${foo} => ${foo}</echo>产出:
[echo] ${foo} => bar在您的示例中,它检查在项目中是否设置了一个名为subPlan的属性,如果${subPlan}不存在,它就不会展开。:
<project>
<property name="subPlan" value="whatever"/>
<echo>${subPlan}</echo>
</project>产出:
[echo] whatever鉴于:
<project>
<echo>${subPlan}</echo>
</project>产出:
[echo] ${subPlan}实际上,可以将属性subPlan的属性值设置为${subPlan}:
<property name="subPlan" value="$${subPlan}"/>但是这是没有意义的,所以您的代码片段是否进行了合并检查,=>是属性subPlan集,并且有一个有用的值?可以这样使用:
<fail message="Property not set or invalid value !">
<condition>
<equals casesensitive="false" arg1="${subPlan}" arg2="$${subPlan}"/>
</condition>
</fail>最后,检查属性是否设置的标准方法是使用isset条件,f.e。:
<fail message="Property not set !">
<condition>
<not>
<isset property="subPlan"/>
</not>
</condition>
</fail>https://stackoverflow.com/questions/22387448
复制相似问题