开发者

Ant load properties from pattern

In ant, I need to load a set of .properties files based on a pattern.

I tried:

<property>  
    <fileset includes="${propertiesDir}/*.properties"/>
</property>

but it doesn't work because <property> doesn't support nesting.

How can i load proper开发者_开发百科ties from files matching a pattern?

Thanks..


You could use the concat task to concat all your properties files to a big temporary properties file, and the use property with this big temporary properties file as attribute.

Make sure to use fixlastline="true" with the concat task to make sure each file ends with a new line character.

Example :

<target name="init">
    <concat destfile="temp/bigPropertiesFile.properties" fixlastline="true">
        <fileset dir="${propertiesDir}" includes="*.properties"/>
    </concat>
    <property file="temp/bigPropertiesFile.properties"/>
</target>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜