views:

50

answers:

2

Hi,

I've just recently started writing Maven plugins and was wondering if there is a common way to modify the values within the pom.xml file e.g. changing an artifacts version number. With the exception of the line being modified I would want the remaining formatting within the xml file to be preserved. I'm just about to start manually doing this via Java DOM libraries, but wanted to check first if there are any Maven convenience classes/functions for this.

Thanks.

+1  A: 

I don't think there's a prescribed way of manipulating the pom. All the plugins I've seen and written use one of the many DOM libraries. The docs for the XOM Serializer explicitly mention that it respects all whitespace unless instructed otherwise.

Barend
+1  A: 

My advice would be to check how this is done in the maven-release-plugin. Actually, the interesting parts are in maven-release-manager. Get the sources and dig :)

Pascal Thivent
Thanks for the link. Looks like they use SaxParser..
Strawberry