Ant 从模式加载属性 [英] Ant load properties from pattern

查看:24
本文介绍了Ant 从模式加载属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

谢谢..

推荐答案

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

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.

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

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

示例:

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

这篇关于Ant 从模式加载属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆