tidy-maven-plugin (https://github.com/mojohaus/tidy-maven-plugin) works similar to versions plugin.
It uses a String copy of pom and for the non-trivial tidy tasks an XMLEventReader from StAX api to manipulate rewrites, and plexus.util.FileUtils.fileWrite to write the pom file out.
