是否有可能指定的属性值在蚂蚁的财产? [英] Is it possible to specify value of property as property in ant?

查看:115
本文介绍了是否有可能指定的属性值在蚂蚁的财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这是由我自己ant脚本执行过程中生成的属性文件。我想从这个生成的属性文件访问属性的值。

I have a property file which is generated by my ant script itself during execution. And I want to access the value of properties from this generated property file.

有关如,

生成的属性文件:

first.prop=abcd
second.prop=pqrs

和脚本,我试图访问这个样子,

and in script, I am trying to access it like this,

我有一些其他财产属性名称(即我想要访问,并在生成的属性文件)。该属性 name.prop
因此,

I am having a property name (that I want to access and is in generated property file) from some other property. That property is name.prop. so,

<echo message="${name.prop}"/>
<echo message="${${name.prop}}"/>

first.prop
${${name.prop}}

分别作为输出。
有什么可以在这个解决方案?

as output respectively. What can be the solution over this?

推荐答案

这是从 DOC

括号嵌套

在其默认的配置蚂蚁不会尝试在平衡牙套
  属性扩展,它只会消耗文本到第一
  创建一个属性的名称时,请关闭括号。即当扩张
  像$ {$一{B}}它会被翻译成两部分:

In its default configuration Ant will not try to balance braces in property expansions, it will only consume the text up to the first closing brace when creating a property name. I.e. when expanding something like ${a${b}} it will be translated into two parts:


      
  • 的属性$ {B膨胀 - 可能没什么用处

  •   
  • 的文字文本}从第二个右括号导致

  •   

这意味着你不能使用轻松地扩展他们的名字是性能
  按属性给出,但也有一些变通办法旧版本
  蚂蚁。使用Ant 1.8.0和 的antlib可以配置蚂蚁
  使用其中定义的NestedPropertyExpander,如果你需要这样的
  功能。

This means you can't use easily expand properties whose names are given by properties, but there are some workarounds for older versions of Ant. With Ant 1.8.0 and the the props Antlib you can configure Ant to use the NestedPropertyExpander defined there if you need such a feature.

所以它不可轻易。解决方法(使用&LT;脚本/&GT; &LT; macrodef /&GT; 可以发现的here在官方FAQ蚂蚁

So it is not available easily. Workarounds (using <script /> or <macrodef /> can be found here in the official ant faq.

这篇关于是否有可能指定的属性值在蚂蚁的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆