How to elegantly customize the pom.xml using the new publishing plugin


Is there a more elegant (Groovy) way than repeatedly calling appendNode() to customize the pom.xml?

publishing {
    publications {
        mavenJava(MavenPublication) {
           pom.withXml {
                asNode().appendNode('name', 'some name')
                asNode().appendNode('description', 'some description')
                        appendNode('id', 'someid').parent().
                        appendNode('name', 'somename').parent().
                        appendNode('email', 'someemail')
                        appendNode('name', 'Apache License, Version 2.0').parent().
                        appendNode('url', '')

Not sure if I’d call it ‘elegant’, but you can use ‘’ to append content using the Groovy XmlMarkupBuilder.

See this forum post for more details:

This is definitely more elegant than what I had before. Thanks, Daz.

This is good stuff to put into a plugin. We put most of the updating of the pom into the nebula-publishing-plugin, and the developers section into the gradle-contacts-plugin. I’m still looking to put the license bits and the scm bits into appropriate plugins.