Thoughts for "shared" information in generated pom in a multi-module build

I like to be thorough in the information I put into the pom generated by Gradle and published with my artifacts. In fact, many repos insist on thorough pom information for uploading to them. However, pom customization in a typical multi-module build shares a lot of information with just a little bit (id, name, description mainly) being specific to each module. To implement this atm I use the subprojects closure from the root project and set up the publishing for every module. For the specific bits I rely on the subprojects defining methods like pomName(), pomDescription(), etc and using them from within the subprojects closure as I define publishing. It works, but it feels quite un-Gradle-like to me. So I have been contemplating ways to make this more Gradle-like (more declarative). I am thinking something along the lines of a Plugin that adds an extension for these “specific bits” and then accesses the publication to alter its pom based on that information.

Is it possible to access the pom for a publication outside the publishing.publications block? If so, how? Is it “just” a NamedDomainObjectContainer?

Yes, publishing.publications is just a NamedDomainObjectContainer, which means the simplest way to implement this is probably just to call all() to defer configuring publications. Here is a real quick stab at what a plugin like you described might look like.

apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: CustomPom

group = ''
version = '1.0.0-SNAPSHOT'

pom {
    description 'Some project'

publishing {
    publications {
        maven(MavenPublication) {

class CustomPom implements Plugin<Project> {
    void apply(Project project) {
        def pomExtension = project.extensions.create('pom', PomExtension)
        project.afterEvaluate {
            project.extensions.getByType(PublishingExtension).publications.all {
                pom.withXml {
                    asNode().appendNode('description', pomExtension.description)

class PomExtension {
    String description

Hey Mark. Thanks for the thoughts. That’s very similar to what I ended up doing. Worked great. Was even able to auto-apply the SNAPSHOT versus release publishing repository handling in this fashion. Thanks