【发布时间】:2010-12-09 18:18:42
【问题描述】:
我正在尝试将两个不同的字符串分配给两个不同的变量,这取决于 Ant 中的两个布尔值。
伪代码(ish):
if(condition)
if(property1 == null)
property2 = string1;
property3 = string2;
else
property2 = string2;
property3 = string1;
我试过的是;
<if>
<and>
<not><isset property="property1"/></not>
<istrue value="${condition}" />
</and>
<then>
<property name="property2" value="string1" />
<property name="property3" value="string2" />
</then>
<else>
<property name="property2" value="string2" />
<property name="property3" value="string1" />
</else>
</if>
但我得到包含“<if>”的行的空指针异常。我可以使用<condition property=...> 标签让它工作,但一次只能设置一个属性。我尝试使用<propertyset>,但这也是不允许的。
你可能已经猜到了,我是 ant 新手 :)。
Gav
【问题讨论】:
标签: ant properties conditional-statements if-statement