使用ant脚本使用两个.properties文件?

bgu*_*uiz 3 ant properties-file

我想知道是否有可能让ant脚本同时引用2个不同的.properties文件,如果是这样,如何实现这一点.

假设两个.properties文件中包含的属性是互斥的,即相同的属性不会出现两次.

谢谢!

Ash*_*Ash 8

您应该能够<property file="...">在蚂蚁脚本中导入任意数量的具有多个条目的属性文件(除非您错过了一些我错过的问题?).重复的属性是可以的,因为在ant属性中是不可变的,并且任何人首先设置属性"wins".

看到 http://ant.apache.org/manual/Tasks/property.html了解更多详情.


Ale*_*yak 7

除了Ash 回答.

您可以使用任务的不同prefix属性property,例如

<property file="file1.properties" prefix="file1"/>
<property file="file2.properties" prefix="file2"/>
Run Code Online (Sandbox Code Playgroud)

这样,您可以查看两个文件是否具有相同的属性,并在构建脚本中区分它们.例如,如果两个文件都具有属性test,则在使用上述命令加载后,您将得到名为file1.test和的属性file2.test.