【问题标题】:Ant load properties from pattern来自模式的蚂蚁负载属性
【发布时间】:2011-02-13 17:48:14
【问题描述】:

在 ant 中,我需要加载一组基于模式的.properties 文件。
我试过了:

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

但它不起作用,因为&lt;property&gt; 不支持嵌套。

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

谢谢..

【问题讨论】:

    标签: java ant


    【解决方案1】:

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

    确保在 concat 任务中使用 fixlastline="true" 以确保每个文件都以换行符结尾。

    例子:

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

    【讨论】:

    • 啊好的。那么,我应该使用: 然后我将列表定义为.properties 文件路径的逗号分隔列表吗?
    • 没有。使用 concat 任务连接所有文件(不是文件名)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-22
    • 1970-01-01
    相关资源
    最近更新 更多