【发布时间】:2011-07-04 05:59:25
【问题描述】:
我正在使用 ant,但我遇到了 if/then/else 任务 (ant-contrib-1.0b3.jar) 的问题。
我正在运行一些可以使用下面的 build.xml 进行简化的东西。
我期待从 'ant -Dgiv=Luke' 获得消息
input name: Luke
should be overwritten with John except for Mark: John
但似乎属性“giv”没有在 if/then/else.. 中被覆盖。
input name: Luke
should be overwritten with John except for Mark: Luke
这是否取决于我将 equals 任务与 ${giv} 一起使用的事实?
否则我的代码有什么问题?
build.xml 代码:
<project name="Friend" default="ifthen" basedir=".">
<property name="runningLocation" location="" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${runningLocation}/antlib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<target name="ifthen">
<echo message="input name: ${giv}" />
<if>
<equals arg1="${giv}" arg2="Mark" />
<then>
</then>
<else>
<property name="giv" value="John" />
</else>
</if>
<echo message="should be overwritten with John except for Mark: ${giv}" />
</target>
</project>
【问题讨论】:
标签: ant ant-contrib