vanniktech / gradle-maven-publish-plugin

A Gradle plugin that publishes your Android and Kotlin libraries, including sources and javadoc, to Maven Central or any other Nexus instance.
https://vanniktech.github.io/gradle-maven-publish-plugin
Apache License 2.0
1.27k stars 118 forks source link

Gradle plugin markers do not contain pom packaging in some cases #841

Open rubensousa opened 1 week ago

rubensousa commented 1 week ago

I just spent quite some time figuring out why my plugin wasn't being found through mavenLocal in a separate project. Turns out that the marker artifact generated by this plugin is missing this in the POM file if I specify pom.packaging=jar for the plugin

<packaging>pom</packaging>

This should be enough to reproduce:

group = "com.example.group"
version = "1.0.0"

gradlePlugin {
    plugins {
        register("plugin") {
            id = "com.example.group"
            implementationClass = "com.example.x.y.Plugin"
        }
    }
}

mavenPublishing {
    configure(
        GradlePlugin(
            javadocJar = JavadocJar.Javadoc(),
            sourcesJar = true
        )
    )
    coordinates(artifactId = "my-plugin")
    pom {
        packaging = "jar"
    }
}

If I remove packaging = "jar" then I get this in the marker POM:

<packaging>pom</packaging>

However, doing that removes the jar packaging from the plugin's artifact POM file:

<packaging>jar</packaging>

Let me know if you need more information and if this is intended.

rubensousa commented 1 week ago

Looks like the plain maven-publish plugin also behaves like this, so this could be the expected structure. Anyway, would be great if we could mention this in the docs to avoid mistakes. If someone specifies packaging = "jar" the setup gets broken