Maven builds for different environments using xml templating - differences too complicated for simply properties or token replacement



I am trying to come up with a solution for managing XML configuration files for multi-environment builds that does not involve maintaining one configuration file for each environment. By XML configuration file, I mean XML files used at run-time, ie web.xml, and not the POM itself. I could of course maintain an XML file for each environment and then define a Maven property that contains the file path and have different Maven profiles that switches this path, but I would prefer a different solution.


Like I am suggesting in the title, the differences are not something that can be accomplished by a simple token replacement - completely different XML structures are required in different environments. I originally tried using the maven Antrun plugin to run Ant's xmltask to add/remove/delete nodes via Xpath, but this is overly verbose and complicated to maintain, especially considering this plugin's inability to properly handle XML namespaces in a non-verbose manner.


Ideally, the XML file would like a normal template file, ie:



<x:if environment="production">
<a b="c">
<d>
</a>
</x:if>
<x:else>
<g />
</x:else>


Note how, like I mentioned above, the node structures are completely different between environments.


Any ideas or suggestions?


No comments:

Post a Comment