ant:exec的宏,用于回显它执行的命令,包括参数
目前我这样做:ant:exec的宏,用于回显它执行的命令,包括参数,ant,arguments,exec,echo,Ant,Arguments,Exec,Echo,目前我这样做: <echo message="cd ${build.dir}/scripts ; ./update.sh ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6} ; cd -" /> <exec dir="${build.dir}/scripts" executable="./update.sh" resultproperty="update.result" > <
<echo message="cd ${build.dir}/scripts ; ./update.sh ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6} ; cd -" />
<exec dir="${build.dir}/scripts"
executable="./update.sh"
resultproperty="update.result" >
<arg value="${arg1}"/>
<arg value="${arg2}"/>
<arg value="${arg3}"/>
<arg value="${arg4}"/>
<arg value="${arg5}"/>
<arg value="${arg6}"/>
</exec>
其结果与上述相同
其中,execWithEcho
将是定义如下的宏:
<macrodef name="execWithEcho">
<attribute name="attr.dir"
description="Directory to run exec in."/>
<attribute name="attr.executable"
description="The executable target."/>
<attribute name="attr.resultProperty"
description="The property to set the retern value of the target executable/"/>
<sequential>
<echo message="//TODO implement echo in execWithEcho"/>
<exec dir="@{attr.dir}"
executable="@{attr.executable}"
resultProperty="@{attr.resultProperty}">
<!-- args go here -->
</exec>
</sequential>
</macrodef>
这里我不确定的是如何迭代传入的所有子
元素;以echo语句所需的方式将它们连接到单个字符串中
提前谢谢 看到马克的答案了吗?把回音放在update.sh中不是比放在ant中更容易吗?
<macrodef name="execWithEcho">
<attribute name="attr.dir"
description="Directory to run exec in."/>
<attribute name="attr.executable"
description="The executable target."/>
<attribute name="attr.resultProperty"
description="The property to set the retern value of the target executable/"/>
<sequential>
<echo message="//TODO implement echo in execWithEcho"/>
<exec dir="@{attr.dir}"
executable="@{attr.executable}"
resultProperty="@{attr.resultProperty}">
<!-- args go here -->
</exec>
</sequential>
</macrodef>