如何将可变数量的参数传递给ant exec

时间:2011-07-21 00:11:19

标签: java ant

我有一个ant目标,它接受一些可传递给exec任务的可变参数。使用旧的机制,这是微不足道的:

<exec command="cmd /c ${_full-path-to-exec}" osfamily="windows" failonerror="true">
</exec>

但是,不推荐使用'command'来支持嵌套元素。像这样:

<exec executable="cmd" osfamily="windows" failonerror="true">
    <arg value="/c"/>
    <arg file="${_full-path-to-exec}"/>
    <arg value="${_param-one}"/>
    <arg value="${_param-two}"/>
    <arg value="${_param-three}"/>
</exec>

这使得变量参数列表变得不可能。

如何解决这个问题?

1 个答案:

答案 0 :(得分:13)

这个怎么样:

 <arg line="whatever args you need"/>