We've got some techniques to do this in the release plugin as well. It may be a good thing to build a solid API (either in Maven proper, or a shared module) either with this, the code from the release plugin, the versions plugin, or a combination of them all and then bring them all into line...
On 14/04/2011, at 12:00 AM, Jesse Glick wrote: > On 04/13/2011 07:56 AM, Julien HENRY wrote: >> I would like to know if there is a standard Maven API to edit parts of a >> pom.xml. I managed to parse a pom to a Model using ModelBuilder. Then I can >> do >> some modifications and write Model to file using ModelWriter. But of course >> it >> will completly rewrite the pom (loosing comments, writing unwanted tags like >> default values, ...). > > The main challenge is finding a library for high-fidelity XML round-trip > structure editing, i.e. that preserves all details of whitespace and > formatting for unmodified nodes. NetBeans has such a system (XAM/XDM) but the > dependency tree is too deep for use in a Maven plugin. > http://code.google.com/p/decentxml/ is the only such small library I can > find. It has its own model rather than Document, DOMImplementationLS, etc., > so your code would be tightly tied to that API. It does not appear to be > published on Central and I am unsure how reliable it is, but it has a Maven > POM utility already, and it seems to work as advertised in my testing - > replacing a few element attribute values on some largish hand-edited XML > files produced a minimal diff. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- Brett Porter [email protected] http://brettporter.wordpress.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
