Ant属性glob进入全局属性空间

时间:2011-11-03 02:41:03

标签: ant build properties

我想做一些类似于从一组属性到一个新属性的属性集,但不是将结果保存在属性集中,而是保存在全局属性空间中。

例如:

<syspropertyset>
    <propertyref prefix="foo."/>
    <mapper type="glob" from="foo.*" to="bar.*"/>
</syspropertyset>

将所有属性(如foo.something)映射到bar.something,但它们通常不会用于其他任务,而是将范围限制在属性集中。

1 个答案:

答案 0 :(得分:0)

您可以使用echoproperties任务并通过属性文件进行操作。类似的东西:

<property name="foo.bar" value="bahh" />
<property name="foo.baz" value="bazz" />

<propertyset id="fooz">
    <propertyref prefix="foo."/>
    <mapper type="glob" from="foo.*" to="bar.*"/>
</propertyset>

<echoproperties destfile="bar.properties">
    <propertyset refid="fooz" />
</echoproperties>
<property file="bar.properties"/>

<echoproperties prefix="foo"/>
<echoproperties prefix="bar"/>

结果(删除了一些措辞以简化):

[echoproperties] foo.bar=bahh
[echoproperties] foo.baz=bazz
[echoproperties] bar.bar=bahh
[echoproperties] bar.baz=bazz