views:

240

answers:

2

Hi,

I want to know if it is possible to get an ant script to reference 2 different .properties files at once, and if so, how to accomplish this.

Assume that the properties contained within the two .properties files are mutually exclusive, i.e. the same property will not appear twice.

Thanks!

+4  A: 

You should be able to import any number of properties files with multiple <property file="..."> entries in your ant script (unless there's some subtlety to your question that I've missed?). Duplicate properties are OK, since in ant properties are immutable and whoever sets the property first "wins".

See http://ant.apache.org/manual/CoreTasks/property.html for more details.

Ash
Thanks for the answer - unfortunately I can only check one answer.
bguiz
+4  A: 

In addition to Ash answer.

You can use a different prefix attribute of property task, e.g

<property file="file1.properties" prefix="file1"/>
<property file="file2.properties" prefix="file2"/>

This way you can find out if both files have same properties and differentiate between them in your build script. For example if both files have property test, then after they are loaded with the above commands you will end up with properties named file1.test and file2.test.

Alexander Pogrebnyak
This is exactly what I was looking for - can't believe I overlooked that!
bguiz