Ant load properties from pattern

孤街醉人 提交于 2019-12-11 07:07:10

问题


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 properties from files matching a pattern?

Thanks..


回答1:


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>


来源:https://stackoverflow.com/questions/4983439/ant-load-properties-from-pattern

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!