我只使用apache-ant而不是 ant-contrib
我有一个ant目标
<target name="stop" depends="init" >
...
</target>
我想在其中调用exec任务。
如果变量的HOST_NAME值为all
<exec executable="${executeSSH.shell}" >
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<arg value="-w 10" />
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
如果变量的HOST_NAME值为anything else
<exec executable="${executeSSH.shell}">
<arg value="-h ${HOST_NAME}" />
<arg value="-i ${INSTANCE}" />
<arg value="-e ${myOperation.shell} " />
<arg value=" -- " />
<arg value="${INSTANCE} ${USERNAME} ${PASSWORD}" />
</exec>
但我只想写一个任务而不是重复exec。我已经使用HOST_NAME了参数,但是如何处理-w 10两个调用中不同的第二个参数。
我已经尝试了几种方法,通过使用搜索 SO condition,if else但似乎没有任何方法适用于execor arg。