-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[BUG] Custom POM configuration for ZIP publication produces duplicit tags (url, scm) #3656
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,6 @@ | |
| 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; | ||
|
|
@@ -57,6 +56,9 @@ | |
| import org.gradle.api.tasks.bundling.Jar; | ||
| import org.gradle.language.base.plugins.LifecycleBasePlugin; | ||
|
|
||
| import java.lang.invoke.MethodHandle; | ||
| import java.lang.invoke.MethodHandles; | ||
| import java.lang.invoke.MethodType; | ||
| import java.util.concurrent.Callable; | ||
|
|
||
| import static org.opensearch.gradle.util.GradleUtils.maybeConfigure; | ||
|
|
@@ -153,16 +155,29 @@ private static void addScmInfo(XmlProvider xml) { | |
| 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; | ||
| final Object name = node.name(); | ||
|
|
||
| try { | ||
| // For Gradle 6.8 and below, the class is groovy.xml.QName | ||
| // For Gradle 7.4 and above, the class is groovy.namespace.QName | ||
| if (name != null && name.getClass().getSimpleName().equals("QName")) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still have to support Gradle 6.x ? Do you still see value?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's basically on plugin authors ... We support it since we don't have control over external community plugins |
||
| final MethodHandle handle = MethodHandles.publicLookup() | ||
| .findVirtual(name.getClass(), "matches", MethodType.methodType(boolean.class, Object.class)) | ||
| .bindTo(name); | ||
|
|
||
| if ((boolean) handle.invoke("url")) { | ||
| url = node; | ||
| } else if ((boolean) handle.invoke("scm")) { | ||
| scm = node; | ||
| } | ||
| } | ||
| } else if ("url".equals(node.name())) { | ||
| } catch (final Throwable ex) { | ||
| // Not a suitable QName type we could use ... | ||
| } | ||
|
|
||
| if ("url".equals(name)) { | ||
| url = node; | ||
| } else if ("scm".equals(node.name())) { | ||
| } else if ("scm".equals(name)) { | ||
| scm = node; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.