I have an XML file where I keep relevant default values for my application, such as the server URL. I use Maven to build my application. My goal is to edit the XML and change the server URL depending on the environment I will be using, such as development, test and production environment.
The XML file is of type plist and cannot be changed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ServerURL</key>
<string>https://server_url</string>
<!-- Other properties goes here -->
</dict>
</plist>
Does anyone know how to solve this?
I have found the xmltask but no working example on how to something like this. I want something that is really simple to perform a simple task like this. Is there maybe a simple Maven plugin that fixes this? I know XPath and it would be nice to use a simple XPath expression to change the XML file.
I’d suggest to use profiles and filtering of resources with maven-resources-plugin for this task.
For example, in your XML config file you can specify server URL like this:
Meanwhile, in your pom.xml file you should define server.url property
and one (or several) profiles that will modify its value