From c0ef536be4808d241f3c4aed8d3dac0f6f4fb8c8 Mon Sep 17 00:00:00 2001 From: zml Date: Wed, 26 Aug 2020 11:33:40 -0700 Subject: [PATCH] Include exclusions in the poms generated for mods (#262) --- .../java/net/fabricmc/loom/AbstractPlugin.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index 4d0972a..155558d 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -38,6 +38,8 @@ import org.gradle.api.Task; import org.gradle.api.UnknownTaskException; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; +import org.gradle.api.artifacts.ExcludeRule; +import org.gradle.api.artifacts.ModuleDependency; import org.gradle.api.artifacts.repositories.MavenArtifactRepository; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginConvention; @@ -397,6 +399,20 @@ public class AbstractPlugin implements Plugin { depNode.appendNode("artifactId", dependency.getName()); depNode.appendNode("version", dependency.getVersion()); depNode.appendNode("scope", entry.getMavenScope()); + + if (dependency instanceof ModuleDependency) { + final Set exclusions = ((ModuleDependency) dependency).getExcludeRules(); + + if (!exclusions.isEmpty()) { + Node exclusionsNode = depNode.appendNode("exclusions"); + + for (ExcludeRule rule : exclusions) { + Node exclusionNode = exclusionsNode.appendNode("exclusion"); + exclusionNode.appendNode("groupId", rule.getGroup() == null ? "*" : rule.getGroup()); + exclusionNode.appendNode("artifactId", rule.getModule() == null ? "*" : rule.getModule()); + } + } + } } })); }