I have .properties file with variables=values, I want to override few of them based on environment/mode (DEV, QA, PROD)
I want to read properties from file based on section. Want to read all default properties which are out of any section and some some properties should be override as per given section name which I can pass from ant script while reading properties file.
---project.properties file (can be modified)---
#default
var1=val1
url=abc.xyz
un=un_default
pwd=pwd_default
#Mode prod
[PROD]
un=un_dev
pwd=pwd_prod
[PROD.END]
#Mode dev
[DEV]
url=xyz.dev
un=un_dev
pwd=pwd_dev
[DEV.END]
#Mode qa
[QA]
un=un_qa
pwd=pwd_qa
[QA.END]
------ ant -----
<property environment="env" />
<echo>Mode : ${env.MODE} </echo>
<loadproperties srcfile="project.properties">
</loadproperties>
Now how to pass ${env.MODE} while reading the properties file so that all default and mode/section properties should load, if default is already there then should be override by value in section.