使用Ant合并两个不同的属性文件 [英] Using Ant to merge two different properties files
本文介绍了使用Ant合并两个不同的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个默认的属性文件,并部署一些特定的属性文件覆盖某个设置默认的基础上,部署环境。我想我的Ant构建脚本来合并两个属性文件(覆盖与部署的具体数值默认值),然后输出所得的属性,以一个新的文件。
我试图做它像这样,但我是不成功的:
<目标取决于=初始化NAME =配置目标环境>
< filterset ID =应用程序 - 属性 - filterset>
< filtersfile文件=$ {build.config.path} / $ {} target.environment /application.properties/>
< / filterset> <副本todir =$ {网络inf.path} / conf目录文件=$ {} build.config.path /application.properties覆盖=真failonerror =真>
< filterset REFID =应用程序 - 属性 - filterset/>
< /复制>
< /目标与GT;
解决方案
我做的是这样的:
<物业preFIX =app.properties文件=custom.application.properties/>
<物业preFIX =app.properties文件=default.application.properties/>
< echoproperties destfile =application.properties>
<&属性集GT;
< propertyref preFIX =app.properties/>
<映射器类型=从=水珠为=*/&GTapp.properties *。
< /属性集>
< / echoproperties>
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>
解决方案
I did it like this:
<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屋!
查看全文