Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing Gradle plugin marker: can't set pom name and description #12259

Closed
gabrielittner opened this issue Feb 17, 2020 · 5 comments · Fixed by #28590
Closed

Publishing Gradle plugin marker: can't set pom name and description #12259

gabrielittner opened this issue Feb 17, 2020 · 5 comments · Fixed by #28590
Assignees
Milestone

Comments

@gabrielittner
Copy link

I want to set the pom name and description like this to satisfy the maven central requirements:

publishing {
    publications.all {
        pom {
            name = 'My Library'
            description = 'A concise description of my library'
            url = 'http://www.example.com/library'
        }
    }
}

Expected Behavior

Generated poms should contain:

<?xml version="1.0" encoding="UTF-8"?>
<project ...>
  ...
  <name>My Library</name>
  <description>A concise description of my library</description>
  <url>http://www.example.com/library</url>
</project>

Current Behavior

The 3 lines exist in the actual artifact's pom. However the pom for the plugin marker does not contain the name and description.

Context

This worked in Gradle 4.10.3. On newer versions it is broken. Tested it with 5.0, 5.6.4, 6.0 and 6.2.

Because of this issue it's not possible to publish plugin markers to maven central.

Steps to Reproduce

This is a sample project with publishing set up. If you run publish it will write to build/repo:
publish-sample.zip

@gabrielittner
Copy link
Author

This seems to be a working workaround:

myPublication.pom.withXml { pom ->
    pom.asNode().appendNode("name", "the name")
    pom.asNode().appendNode("description", "the description")
}

@gabrielittner
Copy link
Author

This is still happening in Gradle 6.8.2

@jjohannes jjohannes added a:bug and removed @jvm a:regression This used to work labels Mar 22, 2021
@gabrielittner
Copy link
Author

gabrielittner commented Sep 13, 2021

This is still happening in Gradle 7.2. Would you accept a fix that only executes these lines when declaration.getDisplayName() and declaration.getDescription() are respectively not null?

@DavidGregory084
Copy link

DavidGregory084 commented Apr 28, 2022

I have found another workaround for this:
https://github.com/opencastsoftware/gradle-build-info/blob/main/build.gradle.kts#L96=

You have to do something similar to get signing of the plugin marker to work too:
https://github.com/opencastsoftware/gradle-build-info/blob/main/build.gradle.kts#L132=

I have no idea how anyone is supposed to figure this out but I found some good info in these threads:
https://discuss.gradle.org/t/adding-custom-artifacts-to-an-existing-publication/18067
https://discuss.gradle.org/t/how-can-i-customize-the-pom-of-the-plugin-marker-artifacts/33053/4

@StefMa
Copy link
Contributor

StefMa commented Dec 18, 2023

Happen still with 8.5.
I fixed it by adding displayName and description to the publings.register from the java-gradle-plugin plugin block:

gradlePlugin {
    plugins.register("some.id") {
        id = "plugin.id"
        implementationClass = "impl.Class"
        displayName = "SameAsInPom"
        description = "Some Description"
    }
}

I guess the plugin should instead of relaying on this properties, fallback to the publishing.publications.pom declaration of the maven-publish plugin in case it is available...

Update

This is the code in quesiton:

publication.getPom().getName().set(declaration.getDisplayName());
publication.getPom().getDescription().set(declaration.getDescription());

it overrides the pom.name and pom.description with the one of the plugin-declaration.
If its not set, there will be nothing in the POM.

I guess a simple check like if !getDisplayName().isEmptyOrNull { setIt() } should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment