I need to edit an XML file with field values taken from a properties file.
The XML file, is in the format as below. ServiceConfig_Template.xml
<field>
<name>HTTP/Server</name>
<value>${Server}</value>
</field>
<field>
<name>HTTP/Port</name>
<value>${Port}</value>
</field>
I have the values of these placeholder variables (Server and Port) defined in separate properties files for each environment (DEV, QA, PROD).
===================================================================
Application_DEV.properties
Server=DEV_Application_Server1
Port=8081
===================================================================
Application_QA.properties
Server=QA_Application_Server11
Port=8082
===================================================================
I would need to populate the ServiceConfig_Template.xml file that is having placeholders (${Server}
and ${Port}
) of the variables; their values being defined in the properties file (Application_DEV.properties), and then write the edited values into a different XML.
How can I use Maven to lookup the variable placeholders values available in the properties file and output the updated XML file(ServiceConfig_Template.xml) accordingly.
The output genetrated for DEV, should be as below.
<field>
<name>HTTP/Server</name>
<value>DEV_Application_Server1</value>
</field>
<field>
<name>HTTP/Port</name>
<value>8081</value>
</field>
There are 100s of variables like these in the "ServiceConfig_Template.xml". How can I use Maven replacer plugin, to do the lookup of the variable field values defined with the ${..}
quotes.
The example shown in the site (http://code.google.com/p/maven-replacer-plugin/), i think replaces only one or few fields. I would request help on arriving at a generic solution for all the variable fields in the "ServiceConfig_Template.xml".
Appreciate help on this.
Thanks -Raghu