-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
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: