Environment variables are not automatically available to be referenced as properties within an Ant build.
Two options for passing an environment variable to Ant:
Supply the variable on the Ant command line as a property definition
Set a prefix to be used to access environment variables via properties
For the first you might use:
$ ant -Dscala_home=$SCALA_HOME
Which would make set the scala_home property for the build.
For the second you might use:
<property environment="env" />
to specify the prefix, then you can see the value in this way:
<echo message="${env.SCALA_HOME}" />
If you somehow have a complex build.xml that relies on an un-prefixed property - ${scala_home} - then you could copy the value over from the environment using
发布评论
评论(1)
环境变量不会自动作为 Ant 构建中的属性进行引用。
将环境变量传递给 Ant 的两个选项:
对于第一个,您可能会使用:
这将为构建设置
scala_home
属性。对于第二个,您可以使用:
指定前缀,然后您可以通过以下方式查看值:
如果您有一个依赖于无前缀属性的复杂 build.xml -
${scala_home}
- 然后您可以使用从环境中复制值(请注意,您可能需要调整环境变量名称中的大小写。)
Environment variables are not automatically available to be referenced as properties within an Ant build.
Two options for passing an environment variable to Ant:
For the first you might use:
Which would make set the
scala_home
property for the build.For the second you might use:
to specify the prefix, then you can see the value in this way:
If you somehow have a complex build.xml that relies on an un-prefixed property -
${scala_home}
- then you could copy the value over from the environment using(Note that you may need to adjust case in environment variable names.)