Skip to content

Commit

Permalink
[BUG] Custom POM configuration for ZIP publication produces duplicit …
Browse files Browse the repository at this point in the history
…tags (url, scm)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Jun 22, 2022
1 parent 621cee9 commit 63ae7ad
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension;
import groovy.util.Node;
import groovy.util.NodeList;
import groovy.xml.QName;

import org.opensearch.gradle.info.BuildParams;
import org.opensearch.gradle.precommit.PomValidationPrecommitPlugin;
import org.opensearch.gradle.util.Util;
Expand Down Expand Up @@ -146,9 +148,36 @@ public String call() throws Exception {

private static void addScmInfo(XmlProvider xml) {
Node root = xml.asNode();
root.appendNode("url", Util.urlFromOrigin(BuildParams.getGitOrigin()));
Node scmNode = root.appendNode("scm");
scmNode.appendNode("url", BuildParams.getGitOrigin());
Node url = null, scm = null;

for (final Object child : root.children()) {
if (child instanceof Node) {
final Node node = (Node) child;
if (node.name() instanceof QName) {
final QName qname = (QName) node.name();
if (qname.matches("url")) {
url = node;
} else if (qname.matches("scm")) {
scm = node;
}
} else if ("url".equals(node.name())) {
url = node;
} else if ("scm".equals(node.name())) {
scm = node;
}
}
}

// Only include URL section if it is not provided in the POM already
if (url == null) {
root.appendNode("url", Util.urlFromOrigin(BuildParams.getGitOrigin()));
}

// Only include SCM section if it is not provided in the POM already
if (scm == null) {
Node scmNode = root.appendNode("scm");
scmNode.appendNode("url", BuildParams.getGitOrigin());
}
}

/** Adds a javadocJar task to generate a jar containing javadocs. */
Expand Down

0 comments on commit 63ae7ad

Please sign in to comment.