I am only using apache-ant and not ant-contrib
I have an ant target
<target name="stop" depends="init" >
...
</target>
In which i want to invoke exec task.
If the value of a variable HOST_NAME is 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>
If the value of a variable HOST_NAME is 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>
But i would like to write only one task and not to repeatexec. I have used HOST_NAME parameter but what to do about the second parameter -w 10 which is different in both calls.
I have tried a couple of ways by searching on SO by using condition and if else but nothing seems to be applicable for exec or arg.