在ant中,我需要加载一组.properties
基于模式的文件。
我尝试过:
<property>
<fileset includes="${propertiesDir}/*.properties"/>
</property>
但它不起作用,因为 <property>
不支持嵌套。
如何从与模式匹配的文件加载属性?
谢谢..
最佳答案
您可以使用concat
将所有属性文件连接到一个大的临时属性文件的任务,并使用 property
使用这个大的临时属性文件作为属性。
确保将 fixlaSTLine="true"与 concat 任务一起使用,以确保每个文件以换行符结尾。
示例:
<target name="init">
<concat destfile="temp/bigPropertiesFile.properties" fixlastline="true">
<fileset dir="${propertiesDir}" includes="*.properties"/>
</concat>
<property file="temp/bigPropertiesFile.properties"/>
</target>
关于java - Ant 从模式加载属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4983439/