# Friendlier way to customize a generated pom?

**URL:** <https://discuss.gradle.org/t/friendlier-way-to-customize-a-generated-pom/4968>\
**Category:** Old Forum Archive\
**Created:** [February 25, 2014, 8:02pm UTC](https://discuss.gradle.org/t/friendlier-way-to-customize-a-generated-pom/4968 "2014-02-25T20:02:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres\_Almiray1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/andres_almiray1/32/121_2.png) [@Andres\_Almiray1](https://discuss.gradle.org/u/Andres_Almiray1)\
**Post date:** [February 25, 2014, 8:02pm UTC](https://discuss.gradle.org/t/friendlier-way-to-customize-a-generated-pom/4968/1 "2014-02-25T20:02:00Z")

</div>

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

```gradle
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](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](https://github.com/stianh/gradle-release-plugin/blob/master/build.gradle#L67)

TIA, Andres

---

<div class="post-metadata">

**Author:** ![daz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daz/32/2475_2.png) [@daz](https://discuss.gradle.org/u/daz)\
**Post date:** [February 25, 2014, 8:53pm UTC](https://discuss.gradle.org/t/friendlier-way-to-customize-a-generated-pom/4968/2 "2014-02-25T20:53:00Z")

</div>

It’s a bit of a trick but you can use [Node.plus()](http://groovy.codehaus.org/api/groovy/util/Node.html#plus(groovy.lang.Closure)) to create new XML content via MarkupBuilder and then add it to the generated POM:

```gradle
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](http://forums.gradle.org/gradle/topics/new_publishing_model_and_pom_customization_via_xmlprovider)

---

<div class="post-metadata">

**Author:** ![Andres\_Almiray1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/andres_almiray1/32/121_2.png) [@Andres\_Almiray1](https://discuss.gradle.org/u/Andres_Almiray1)\
**Post date:** [February 25, 2014, 9:41pm UTC](https://discuss.gradle.org/t/friendlier-way-to-customize-a-generated-pom/4968/3 "2014-02-25T21:41:00Z")

</div>

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](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](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](https://github.com/griffon/griffon/blob/master/gradle/maven.gradle)

Much more readable and manageable I’d say.
