来自模式的Ant加载属性

时间:2011-02-13 09:32:18

标签: java ant

在ant中,我需要根据模式加载一组.properties个文件 我试过了:

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

但它不起作用,因为<property>不支持嵌套。

如何从匹配模式的文件中加载属性?

谢谢..

1 个答案:

答案 0 :(得分:2)

您可以使用concat任务将所有属性文件连接到一个大的临时属性文件,并使用property将此大临时属性文件作为属性。

确保使用conclast任务使用fixlastline =“true”以确保每个文件以换行符结束。

示例:

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