Skip to content

Commit

Permalink
Relax strict Minecraft dependency version requirements for legacy pro…
Browse files Browse the repository at this point in the history
…jects (#189)
  • Loading branch information
shartte authored Dec 2, 2024
1 parent 9996c85 commit d897dee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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("");
});
}
});
});
}
}

0 comments on commit d897dee

Please sign in to comment.