Friendlier way to customize a generated pom?

Is there a friendlier way to customize a pom when using the maven-publish plugin? Looking at the Gradle Guide (section 65.2.4) we get something like the following

publications {
    mavenCustom(MavenPublication) {
        pom.withXml {
            asNode().appendNode('description', 'A demonstration of maven POM customization')
        }
    }
}

Basically write XML using Groovy’s node abstraction. This is hardly any better than writing XML by hand. In the past (with the maven plugin) we used to have a very friendly markup (probably backed by MarkupBuilder) as pointed by http://forums.gradle.org/gradle/topics/customize_the_pom_for_install_and_upload -> https://github.com/stianh/gradle-release-plugin/blob/master/build.gradle#L67

TIA, Andres

It’s a bit of a trick but you can use Node.plus() to create new XML content via MarkupBuilder and then add it to the generated POM:

publishing {
  publications {
    maven(MavenPublication) {
      pom.withXml {
        asNode().children().last() + {
            here {
               is "some"
               markupBuilder "content"
            }
        }
      }
    }
  }
}

For more details see http://forums.gradle.org/gradle/topics/new_publishing_model_and_pom_customization_via_xmlprovider

True, but then again that’s just mixing two Groovy APIs for dealing with XML. Also, this example highlights another problem: the current XML processing mechanism expects nodes to be appended. I know it’s possible to insert nodes anywhere you want to but the API is cumbersome at best

Look for example at a recently published pom for livereload-gradle-plugin

http://dl.bintray.com/aalmiray/kordamp/org/kordamp/livereload-gradle-plugin/0.0.1/#livereload-gradle-plugin-0.0.1.pom

which is generated using https://raw.githubusercontent.com/aalmiray/livereload-gradle-plugin/master/build.gradle

The pom contains all the required information but it’s in the “wrong” order (thank goodness maven does not enforce a strict DTD (I think)). Now look at the old way of pom customization using the maven plugin

https://github.com/griffon/griffon/blob/master/gradle/maven.gradle

Much more readable and manageable I’d say.