I've just recently started writing Maven plugins and was wondering if there is a co开发者_JS百科mmon 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.
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 :)
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.
精彩评论