diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java index 68eec319..2c6caa13 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java @@ -40,6 +40,9 @@ public void apply(Project project) { project.getDependencies().getComponents().withModule("net.neoforged:forge", LegacyForgeMetadataTransform.class); project.getDependencies().getComponents().withModule("net.minecraftforge:forge", LegacyForgeMetadataTransform.class); project.getDependencies().getComponents().withModule("de.oceanlabs.mcp:mcp_config", McpMetadataTransform.class); + // For legacy versions we need to relax the strict version requirements imposed by the minecraft-dependencies, + // since Forge upgrades especially log4j2, but we have no way of fixing its metadata fully (besides doing it statically). + project.getDependencies().getComponents().withModule("net.neoforged:minecraft-dependencies", NonStrictDependencyTransform.class); var depFactory = project.getDependencyFactory(); var autoRenamingToolRuntime = project.getConfigurations().create(CONFIGURATION_TOOL_ART, spec -> { diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/NonStrictDependencyTransform.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/NonStrictDependencyTransform.java new file mode 100644 index 00000000..f911b7ca --- /dev/null +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/NonStrictDependencyTransform.java @@ -0,0 +1,26 @@ +package net.neoforged.moddevgradle.legacyforge.internal; + +import org.gradle.api.artifacts.CacheableRule; +import org.gradle.api.artifacts.ComponentMetadataContext; +import org.gradle.api.artifacts.ComponentMetadataRule; + +/** + * Relaxes all strict version constraints to just be required. + */ +@CacheableRule +public class NonStrictDependencyTransform implements ComponentMetadataRule { + @Override + public void execute(ComponentMetadataContext context) { + context.getDetails().allVariants(variant -> { + variant.withDependencies(dependencies -> { + for (var dependency : dependencies) { + dependency.version(version -> { + version.prefer(version.getStrictVersion()); + version.require(version.getStrictVersion()); + version.strictly(""); + }); + } + }); + }); + } +}