asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
286 stars 122 forks source link

Invalid description in published POM #706

Open abelsromero opened 10 months ago

abelsromero commented 10 months ago

Description of deployed POMs has a dot in the description <description>.</description> instead of the actual one.

As per https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/702#issuecomment-1883134976 We should anyway rather refactor that pomXml code to be done in buildSrc rather than in publishing.gradle. It should also be easy to make it conditional to only be done when the maven-publish plugin is applied in the build.

Conversation started in https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/702#issuecomment-1882991096

aalmiray commented 10 months ago

FWIW PomChecker may be used to validate poms before publication https://kordamp.org/pomchecker/pomchecker-gradle-plugin/index.html

ysb33r commented 10 months ago

@aalmiray It would be great if you can integrate kordamp/jreleaser when you have time.

abelsromero commented 10 months ago

I was able to make a quick-fix but there's something wrong under the hood.

By default without any configuration, 2 publications are created, for example for asciidoctor-gradle-base, orgasciidoctorbasePluginPluginMarkerMaven and pluginMaven 🤷 I suspect Groolifant.

image

The pom failing validation is orgasciidoctorbasePluginPluginMarkerMaven (below) which has the dot. But the pom actually being published in my local repo is pluginMaven which a plain simple one.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.asciidoctor.base</groupId>
  <artifactId>org.asciidoctor.base.gradle.plugin</artifactId>
  <version>4.0.1</version>
  <packaging>pom</packaging>
  <name>Asciidoctor Base Plugin</name>
  <description>.</description>
  <dependencies>
    <dependency>
      <groupId>org.asciidoctor</groupId>
      <artifactId>asciidoctor-gradle-base</artifactId>
      <version>4.0.1</version>
    </dependency>
  </dependencies>
</project>

The quickfix is to override pluginMaven with some older code (slightly modified).

publishing {
    publications {
        pluginMaven(MavenPublication) {
            pom.withXml {
                asNode().children().last() + project.ext.pomConfig
                asNode().appendNode('description', project.project_description)
            }
        }
    }
}
ysb33r commented 10 months ago

I won't be Grolifant as it contains no code related to POM management.

aalmiray commented 10 months ago

PluginMarker comes from Gradle's plugin publish plugin which does not care about additional POM properties at all.

I wouldn't push much into this as proper POM elements make sense when publishing to Maven Central but not to the Gradle Plugin Portal.