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

[BUG] Custom POM configuration for ZIP publication produces duplicit tags (url, scm) #3649

Closed
lukas-vlcek opened this issue Jun 22, 2022 · 2 comments · Fixed by #3656
Closed
Labels
bug Something isn't working Build Libraries & Interfaces v2.0.0 Version 2.0.0 v2.1.0 Issues and PRs related to version 2.1.0 v3.0.0 Issues and PRs related to version 3.0.0

Comments

@lukas-vlcek
Copy link
Contributor

Describe the bug

As an plugin author I want to configure top level POM values for project <url> and <scm> tags.
But the generated POM file contains duplicated tags, one with the custom value and second with unknown value.

This also leads to the following validation error:

* What went wrong:
Execution failed for task ':validatePluginZipPom'.
> org.codehaus.plexus.util.xml.pull.XmlPullParserException: Duplicated tag: 'url' (position: START_TAG seen ...</url>\n  </scm>\n  <url>... @28:8) 

To Reproduce

The following is the publishing task configuration in my plugin build.gradle:

publishing {
    publications {
        pluginZip(MavenPublication) { publication ->
            pom {
                name = pluginName
                description = pluginDescription
                licenses {
                    license {
                        name = "The Apache License, Version 2.0"
                        url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    }
                }
                developers {
                    developer {
                        name = "Lukáš Vlček"
                        url = "https://github.com/lukas-vlcek/"
                        organization = "Aiven.io"
                        organizationUrl = "https://aiven.io/"
                    }
                }
                url = "https://github.com/aiven/prometheus-exporter-plugin-for-opensearch"
                scm {
                    url = "https://github.com/aiven/prometheus-exporter-plugin-for-opensearch"
                }
            }
        }
    }
}

And the following is generated POM.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.opensearch.plugin</groupId>
  <artifactId>prometheus-exporter</artifactId>
  <version>2.0.1.0</version>
  <packaging>zip</packaging>
  <name>prometheus-exporter</name>
  <description>Prometheus exporter plugin for OpenSearch</description>
  <url>https://github.com/aiven/prometheus-exporter-plugin-for-opensearch</url>
  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Lukáš Vlček</name>
      <url>https://github.com/lukas-vlcek/</url>
      <organization>Aiven.io</organization>
      <organizationUrl>https://aiven.io/</organizationUrl>
    </developer>
  </developers>
  <scm>
    <url>https://github.com/aiven/prometheus-exporter-plugin-for-opensearch</url>
  </scm>
  <url>unknown</url>
  <scm>
    <url>unknown</url>
  </scm>
</project>

Both the <url> and <scm> tags are duplicated, and they contain value unknown in one case.

Expected behavior

A valid POM file with correct values in <url> and <scm> tags.

Plugins

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.yaml-rest-test'
apply plugin: 'opensearch.pluginzip'

Screenshots
N/A

Host/Environment (please complete the following information):

  • OpenSearch version: 2.0.1

Additional context

When url and scm tags are left out of publishing task configuration (which seems to be the case of all examples that I found) then still these tags are generated and added into POM with value unknown. As far as I understand this is because maven repository can have specific validation rules setup and presence of specific tags is required. Hence a hard-coded set of validation rules was implemented as part of PomValidationTask.checkPom() to fulfil requirements of maven central. Currently, it would be problematic for plugin authors to publish artifacts to repository if it enforces different set of validation rules.

Possible related tickets:

@lukas-vlcek lukas-vlcek added bug Something isn't working untriaged labels Jun 22, 2022
@saratvemulapalli
Copy link
Member

@prudhvigodithi could you take a look at this?

@reta
Copy link
Collaborator

reta commented Jun 22, 2022

@prudhvigodithi could you take a look at this?

@saratvemulapalli @prudhvigodithi I will take it, found the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Build Libraries & Interfaces v2.0.0 Version 2.0.0 v2.1.0 Issues and PRs related to version 2.1.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants