带参数的 Ant 任务 [英] Ant task with argument
问题描述
我必须通过 Apache config.xml 配置 IPV6.我通过 ADDR6 读取 IP.我想将它传递给这样的命令 -ant -f config.xml configureForIPv6
.目标很容易通过,但我如何为 IP 传递参数?Ant 不喜欢 arg 值.
I have to configure IPV6 through Apache config.xml. I read the IP through ADDR6. I want to pass it to the command like this - ant -f config.xml configureForIPv6 <IP>
. The target is easy to pass, but how do i pass the argument for IP? Ant does not like the arg value.
<ant antfile="${APACHE_HOME}/config.xml" target="configureForIPv6" arg="-DIPv6_Interface=${ADDR6}" inheritRefs="true"> ?
推荐答案
您可以通过两种方式 从命令行设置属性.
There are two ways you might set properties from the command line.
首先,对于任何 Java 应用程序,使用 -D
来定义属性:
First, as for any Java application, use -D
to define the property:
ant -f config.xml configureForIPv6 -DADDR=<IP>
其次,将值(或多个值)放入 Java 属性文件(比如名为settings.txt")中,内容可能是:
Second, put the value (or values) in a Java property file (say called 'settings.txt'), content might be:
ADDR=<IP>
然后使用 Ant -propertyfile
选项读取文件,例如:
then read the file using the Ant -propertyfile
option, e.g.:
ant -f config.xml configureForIPv6 -propertyfile settings.txt
这篇关于带参数的 Ant 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!