使用 Ant 合并两个不同的属性文件 [英] Using Ant to merge two different properties files

查看:26
本文介绍了使用 Ant 合并两个不同的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个默认属性文件,以及一些特定于部署的属性文件,这些文件会根据部署环境覆盖默认设置中的某些设置.我希望我的 Ant 构建脚本合并两个属性文件(用部署特定的值覆盖默认值),然后将生成的属性输出到一个新文件.

I have a default properties file, and some deployment specific properties files that override certain settings from the default, based on deployment environment. I would like my Ant build script to merge the two properties files (overwriting default values with deployment specific values), and then output the resulting properties to a new file.

我尝试这样做,但没有成功:

I tried doing it like so but I was unsuccessful:

<target depends="init" name="configure-target-environment">
    <filterset id="application-properties-filterset">
        <filtersfile file="${build.config.path}/${target.environment}/application.properties" />
    </filterset>

    <copy todir="${web-inf.path}/conf" file="${build.config.path}/application.properties" overwrite="true" failonerror="true" >
        <filterset refid="application-properties-filterset" />
    </copy>
</target>

推荐答案

我是这样做的:

<property prefix="app.properties" file="custom.application.properties" />
<property prefix="app.properties" file="default.application.properties" />
<echoproperties destfile="application.properties">
   <propertyset>
      <propertyref prefix="app.properties"/>
      <mapper type="glob" from="app.properties.*" to="*"/>
   </propertyset>
</echoproperties>

这篇关于使用 Ant 合并两个不同的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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