java - Ant 从模式加载属性

标签 java ant

在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/

相关文章:

gradle - 为什么此gradle脚本给我一个错误?

java - 非法访问错误: tried to access class while building Android with ANT

java - 未找到 jdbc 类 spring mvc

java - 比较字符串中各个字母的循环

java - 如何停止在 IntelliJ 中运行的进程以调用关闭 Hook ?

java - 删除java中数组列表中最小的2个元素?

java - 类型不匹配 : cannot convert from java. lang.String 到 String

java - 有没有专门针对 Java 项目的好的 NSIS 替代方案?

java - Apache Ivy 和本地 Maven 存储库 - 如何处理使用 Maven 3 构建的快照

ant - 使用不同的参数多次调用ant目标