我需要在Ant中使用if-else if-else条件语句。
我不想使用Ant-contrib。
我尝试了解决方案here
<target name="condition.check">
<input message="Please enter something: " addproperty="somethingProp"/>
<condition property="allIsWellBool">
<not>
<equals arg1="${somethingProp}" arg2="" trim="true"/>
</not>
</condition>
</target>
<target name="if" depends="condition.check, else" if="allIsWellBool">
<echo message="if condition executes here"/>
</target>
<target name="else" depends="condition.check" unless="allIsWellBool">
<echo message="else condition executes here"/>
</target>但是我必须在if和else目标中设置属性,这些属性在调用目标中是不可见的。
有没有其他使用条件的方法?
发布于 2013-04-11 03:56:17
将依赖项从if和else移到一个依赖于所有其他目标的新目标中:
<project name="ant-if-else" default="newTarget">
<target name="newTarget" depends="condition.check, if, else"/>
<target name="condition.check">
<input message="Please enter something: " addproperty="somethingProp"/>
<condition property="allIsWellBool">
<not>
<equals arg1="${somethingProp}" arg2="" trim="true"/>
</not>
</condition>
</target>
<target name="if" if="allIsWellBool">
<echo message="if condition executes here"/>
</target>
<target name="else" unless="allIsWellBool">
<echo message="else condition executes here"/>
</target>
</project>https://stackoverflow.com/questions/15912976
复制相似问题