【问题标题】:Ant task with argument带参数的蚂蚁任务
【发布时间】:2011-03-04 06:22:02
【问题描述】:

我必须通过 Apache config.xml 配置 IPV6。我通过 ADDR6 读取 IP。我想将它传递给这样的命令- ant -f config.xml configureForIPv6 <IP>。目标很容易传递,但我如何传递 IP 参数? Ant 不喜欢 arg 值。

<ant antfile="${APACHE_HOME}/config.xml" target="configureForIPv6" arg="-DIPv6_Interface=${ADDR6}" inheritRefs="true"> ?

【问题讨论】:

    标签: apache ant


    【解决方案1】:

    您可以通过两种方式set properties from the command line。

    首先,对于任何Java应用程序,使用-D来定义属性:

    ant -f config.xml configureForIPv6 -DADDR=<IP>
    

    其次,将值(或值)放入 Java 属性文件(例如称为“settings.txt”)中,内容可能是:

    ADDR=<IP>
    

    然后使用 Ant -propertyfile 选项读取文件,例如:

    ant -f config.xml configureForIPv6 -propertyfile settings.txt
    

    【讨论】:

    • 当我使用-propertyfile=value ant 时抱怨:“使用 -propertyfile 参数时必须指定属性文件名”。我不得不使用-propertyfile value
    • Martin 谢谢,我让它像下面给出的那样运行;通过在我的文件本身中设置属性来继承属性谢谢 Praveen
    猜你喜欢
    • 2011-04-17
    • 1970-01-01
    • 2011-12-29
    • 2013-12-04
    • 1970-01-01
    • 2011-10-15
    • 2015-05-30
    • 2012-10-09
    • 2016-01-18
    相关资源
    最近更新 更多