How can I customize the pom of the Plugin Marker Artifacts

In a maven repository the Plugin Marker is a pom file with these coordinates:

  • groupId: plugin.id
  • artifactId: plugin.id.gradle.plugin
  • version: plugin.version

This is a POM file that points to the real jar doing the implementation.

See Plugin Markers


According to issue #5808 and its companion design spec document, it should be possible to customize the generated pom for the Plugin Marker.

My goal is to make it fulfill the Maven Central requirements (you need to have a name, some license, some developer…), but I did not found any information about how the groovy-dsl looks like.

I have tried:

publishing {
    publications {
        pluginMaven(MavenPublication) {
            pom {
                name = 'XXX'
            }
        }
        mavenJava(MavenPublication) {
            //... other configuration for the normal jar and pom
        }
    }
}

But my “pluginMaven” bloc under “publications” seems to be ignored.

I am applying these plugins to my grade build:

plugins {
    id 'java-gradle-plugin'
    id 'signing'
    id 'maven-publish'
    id 'de.marcphilipp.nexus-publish' version '0.3.0'
    id 'io.codearte.nexus-staging' version '0.21.0'
}

Gradle version: 5.5.1.

Thank you in advance for your help.

I got a reply from Marc Philipp!

He wrote a small example hosted here:

The relevant point is to use an “afterEvaluate” callback.

publishing {
    // afterEvaluate is necessary because java-gradle-plugin
    // creates its publications in an afterEvaluate callback
    afterEvaluate {
        publications {
            withType(MavenPublication) {
                // customize all publications here
                pom {
                    inceptionYear = "2019"
                }
            }
            pluginMaven {
                // customize main publications here
                pom {
                    name = "main artifact"
                }
            }
            helloPluginMarkerMaven {
                // customize marker publications here
                pom {
                    name = "marker artifact"
                }
            }
        }
    }
    //...
}

Hello! This is exactly what I need but it doesn’t all work for me.

I’m a newbie with gradle I’m working with a build.gradle.kts file. It creates a mavenJava artifact and the plugin marker pom.

The withType block works completely for the mavenJava pom. But the Plugin Marker pom is missing project description and name. It picked up everything else from this block. I dont’ know why so I’m trying to manipulate the pom for the plugin marker itself. But my-pluginPluginMarkerMaven doesn’t resolve in my build script.

Any suggestions? What is syntax for targeting the marker pom directly in the publication block?

publishing {
    afterEvaluate {
        publications {
            withType(MavenPublication) {
                pom {
                    name.set(project.name)
                    description.set(description}
                    //other pom details
                   }
             }
             // this is unresolved and the build fails
             my-pluginPluginMarkerMaven {
             
             }

I guess my-pluginPluginMarkerMaven is not the correct name

It is something: <id-of-the-plugin>PluginMarkerMaven where <id-of-the-plugin> depends of your plugin.

How is your plugin declared? in Marc Philipp’s example it is hello:

gradlePlugin {
    plugins {
        hello {
            id = "${group}.hello"
            implementationClass = "de.marcphilipp.gradle.example.HelloPlugin"
            displayName = "Hello plugin"
            description = "Plugin that can say hello"
        }
    }
}

I am not sure dash - are allowed. I can’t change hello to my-plugin:

gradlePlugin {
    plugins {
        my-plugin {
            id = "${group}.hello"
            implementationClass = "de.marcphilipp.gradle.example.HelloPlugin"
            displayName = "Hello plugin"
            description = "Plugin that can say hello"
        }
    }
}

Even without the publications section, I get this error:

A problem occurred configuring root project 'plugin-maven-publish'.
> Missing id for my