Ant可以扩大从属性的环境变量文件?

编程入门 行业动态 更新时间:2024-10-26 22:16:40
本文介绍了Ant可以扩大从属性的环境变量文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个关于Ant和它的治疗环境变量的问题。为了说明我有一个小样本。

I have a question regarding Ant and its treatment of environment variables. To illustrate I have a small sample.

由于Ant构建文件的test.xml:

Given the Ant build file test.xml:

<project name="myproj" default="testProps"> <property environment="env"/> <target name="testProps"> <echo message="${env.MyEnvVar}"/> <echo message="${MY_PROPERTY}"/> </target> </project>

和属性文件test.props:

And the properties file test.props:

MY_PROPERTY=${env.MyEnvVar}

现在设置环境变量 MyEnvVar 到某一值(富在我的情况),并使用此命令行运行Ant:

Now set the environment variable MyEnvVar to some value (foo in my case) and run Ant using this command line:

ant -f test.xml -propertyfile test.props testProps

我得到的输出是:

The output I get is:

[echo] foo [echo] ${env.MyEnvVar}

我想知道的是是否有任何方式结构中的输入属性文件,这样我得到

What I would like to know is whether there is any way to structure the input properties file such that I get

[echo] foo [echo] foo

这就是我想的名字在被替换的Ant脚本中的属性文件中的环境变量。注 - 我知道如何直接访问环境变量(如在这里完成)。我需要做的是利用一组期望在使用不同的名称定义相同属性的环境属性的一个集合Ant脚本的。因此,在属性文件架桥他们。想到

That is, I would like to name an environment variable in the properties file which is replaced within the Ant script. Note - I know how to access environment variables directly (as is done here). What I need to do is make use of a set of Ant scripts that expect one collection of properties in an environment that defines the same properties using different names. Thus the thought of "bridging" them in a properties file.

我使用Ant版本1.6.5。

I am using Ant version 1.6.5.

推荐答案

您需要阅读 test.props 属性文件的之后的环境 - 你可以这样做使用另一个属性任务,即添加

You need to read the test.props property file after the environment - you could do so using another property task, i.e. add

<property file="test.props" />

您现有的物业环境之后任务。

在全:

<property environment="env" /> <property file="test.props" /> <target name="testProps"> <echo message="${env.MyEnvVar}"/> <echo message="${MY_PROPERTY}"/> </target>

当您提供性能的命令行这被构建的内容之前处理上的文件,但当时 $ {env.MyEnvVar} 尚未设置

When you supply the properties file on the command line this gets processed before the content of the build, but at that time ${env.MyEnvVar} is not yet set.

更多推荐

Ant可以扩大从属性的环境变量文件?

本文发布于:2023-06-05 01:12:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/508797.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:从属性   环境变量   文件   Ant

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!