我正在使用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
Run Code Online (Sandbox Code Playgroud)
但似乎属性"giv"不会被覆盖在if/then/else中.
input name: Luke
should be overwritten with John except for Mark: Luke
Run Code Online (Sandbox Code Playgroud)
是否取决于我使用等于任务的事实${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: …Run Code Online (Sandbox Code Playgroud)