From a0c2d877af42a908c3600461603a66c6dba5af64 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sun, 1 Aug 2021 01:46:42 +0300 Subject: [PATCH] Add modCompileOnlyApi, modRuntimeOnly; deprecate modRuntime (#458) --- .../java/net/fabricmc/loom/build/ModCompileRemapper.java | 5 +++++ .../loom/configuration/RemappedConfigurationEntry.java | 7 ++++++- src/main/java/net/fabricmc/loom/util/Constants.java | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java index cd0633d..0a3dca0 100644 --- a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java +++ b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java @@ -151,6 +151,11 @@ public class ModCompileRemapper { for (ModDependencyInfo info : modDependencies) { project.getDependencies().add(info.targetConfig.getName(), info.getRemappedNotation()); } + + // Report deprecation warnings + if (entry.replacedWith() != null && !modDependencies.isEmpty()) { + extension.getDeprecationHelper().replaceWithInLoom0_11(entry.sourceConfiguration(), entry.replacedWith()); + } }); } } diff --git a/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java b/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java index 228ec34..5e4cf31 100644 --- a/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java +++ b/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java @@ -26,8 +26,13 @@ package net.fabricmc.loom.configuration; import org.gradle.api.artifacts.ConfigurationContainer; import org.gradle.api.plugins.JavaPlugin; +import org.jetbrains.annotations.Nullable; + +public record RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope, @Nullable String replacedWith) { + public RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope) { + this(sourceConfiguration, targetConfiguration, isOnModCompileClasspath, mavenScope, null); + } -public record RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope) { public boolean hasMavenScope() { return mavenScope != null && !mavenScope.isEmpty(); } diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java index 1495ba4..38b5270 100644 --- a/src/main/java/net/fabricmc/loom/util/Constants.java +++ b/src/main/java/net/fabricmc/loom/util/Constants.java @@ -45,8 +45,10 @@ public class Constants { public static final List MOD_COMPILE_ENTRIES = ImmutableList.of( new RemappedConfigurationEntry("modApi", JavaPlugin.API_CONFIGURATION_NAME, true, "compile"), new RemappedConfigurationEntry("modImplementation", JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, true, "runtime"), - new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, ""), - new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "") + new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, "", "modRuntimeOnly"), + new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, ""), + new RemappedConfigurationEntry("modCompileOnlyApi", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "compile"), + new RemappedConfigurationEntry("modRuntimeOnly", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, "runtime") ); private Constants() {