【问题标题】:How to pass a variable number of arguments to ant exec如何将可变数量的参数传递给ant exec
【发布时间】:2011-10-09 20:14:56
【问题描述】:

我有一个 ant 目标,它接受可变数量的要传递给 exec 任务的参数。使用旧机制很简单:

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

但是,不推荐使用“命令”以支持嵌套元素。像这样:

<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>

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

如何解决这个问题?

【问题讨论】:

    标签: java ant


    【解决方案1】:

    这个怎么样:

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

    【讨论】:

    • 咕哝,咕哝,咕哝……这到底是从哪里来的?我向上帝发誓,我已经多次查看该文档,但从未见过 d*$&m 属性。谢谢。
    • 这实际上是 exec ant 页面上的第一个示例。不用担心,这发生在我们所有人身上:)
    • 这一切都很好,但是有些用例必须使用arg 元素的value 属性,因为line 属性不起作用。它们并不总是可以互换的。见:stackoverflow.com/a/9562235/274677
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 2010-11-28
    • 2011-10-12
    相关资源
    最近更新 更多