From 6b0ebe1b3e7222673537397445d0b0516f381a92 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:12:49 +0200 Subject: [PATCH] Update to architectury-loom-runtime 2.0 --- gradle/runtime.libs.versions.toml | 6 +++-- .../configuration/LoomConfigurations.java | 10 +++++-- .../task/launch/GenerateDLIConfigTask.java | 27 ++++++++++++------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/gradle/runtime.libs.versions.toml b/gradle/runtime.libs.versions.toml index 6074369ac..4dbd8262f 100644 --- a/gradle/runtime.libs.versions.toml +++ b/gradle/runtime.libs.versions.toml @@ -13,7 +13,7 @@ native-support = "1.0.1" # Forge Runtime depedencies javax-annotations = "3.0.2" -forge-runtime = "1.1.8" +forge-runtime = "2.0.9999" access-transformers = "3.0.1" access-transformers-new = "8.0.5" unprotect = "1.2.0" @@ -34,7 +34,9 @@ native-support = { module = "net.fabricmc:fabric-loom-native-support", version.r # Forge Runtime depedencies javax-annotations = { module = "com.google.code.findbugs:jsr305", version.ref = "javax-annotations" } -forge-runtime = { module = "dev.architectury:architectury-loom-runtime", version.ref = "forge-runtime" } +mixin-remapper-service = { module = "dev.architectury:architectury-mixin-remapper-service", version.ref = "forge-runtime" } +naming-service = { module = "dev.architectury:architectury-naming-service", version.ref = "forge-runtime" } +mcp-annotations = { module = "dev.architectury:mcp-annotations", version.ref = "forge-runtime" } access-transformers = { module = "net.minecraftforge:accesstransformers", version.ref = "access-transformers" } access-transformers-new = { module = "net.minecraftforge:accesstransformers", version.ref = "access-transformers-new" } unprotect = { module = "io.github.juuxel:unprotect", version.ref = "unprotect" } diff --git a/src/main/java/net/fabricmc/loom/configuration/LoomConfigurations.java b/src/main/java/net/fabricmc/loom/configuration/LoomConfigurations.java index 2ea1b77b5..509aa975b 100644 --- a/src/main/java/net/fabricmc/loom/configuration/LoomConfigurations.java +++ b/src/main/java/net/fabricmc/loom/configuration/LoomConfigurations.java @@ -157,10 +157,16 @@ public void run() { extendsFrom(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, Constants.Configurations.FORGE_EXTRA); extendsFrom(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME, Constants.Configurations.FORGE_EXTRA); - // Add Forge dev-time dependencies - getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.FORGE_RUNTIME.mavenNotation()); + // Add Forge/NeoForge shared dev-time dependencies + getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.NAMING_SERVICE.mavenNotation()); getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.UNPROTECT.mavenNotation()); getDependencies().add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, LoomVersions.JAVAX_ANNOTATIONS.mavenNotation()); + + // Add Forge-only dev-time dependencies + if (extension.isForge()) { + getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.MIXIN_REMAPPER_SERVICE.mavenNotation()); + getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.MCP_ANNOTATIONS.mavenNotation()); + } } } diff --git a/src/main/java/net/fabricmc/loom/task/launch/GenerateDLIConfigTask.java b/src/main/java/net/fabricmc/loom/task/launch/GenerateDLIConfigTask.java index 8056f7c48..f9bf6b27c 100644 --- a/src/main/java/net/fabricmc/loom/task/launch/GenerateDLIConfigTask.java +++ b/src/main/java/net/fabricmc/loom/task/launch/GenerateDLIConfigTask.java @@ -109,13 +109,14 @@ public void run() throws IOException { .map(File::getAbsolutePath) .collect(Collectors.joining(File.pathSeparator)); + final String intermediateNs = IntermediaryNamespaces.intermediary(getProject()); + final String mappingsPath = getExtension().getPlatformMappingFile().toAbsolutePath().toString(); + launchConfig - // Should match YarnNamingService.PATH_TO_MAPPINGS in forge-runtime - // TODO (Neo): Can we rename this property for Neo? It's not at all accurate. - .property("fabric.yarnWithSrg.path", getExtension().getPlatformMappingFile().toAbsolutePath().toString()) .property("unprotect.mappings", unprotectMappings) - - .property("mixin.env.remapRefMap", "true"); + // See ArchitecturyNamingService in forge-runtime + .property("architectury.naming.sourceNamespace", intermediateNs) + .property("architectury.naming.mappingsPath", mappingsPath); final List dataGenMods = getExtension().getForge().getDataGenMods(); @@ -129,11 +130,17 @@ public void run() throws IOException { .argument("data", getProject().file("src/generated/resources").getAbsolutePath()); } - if (PropertyUtil.getAndFinalize(getExtension().getForge().getUseCustomMixin())) { - final String intermediaryNs = IntermediaryNamespaces.intermediary(getProject()); - launchConfig.property("mixin.forgeloom.inject.mappings.srg-named", getExtension().getMappingConfiguration().getReplacedTarget(getExtension(), intermediaryNs).toAbsolutePath().toString()); - } else { - launchConfig.property("net.minecraftforge.gradle.GradleStart.srg.srg-mcp", getExtension().getMappingConfiguration().srgToNamedSrg.toAbsolutePath().toString()); + if (getExtension().isForge()) { + launchConfig.property("mixin.env.remapRefMap", "true"); + + if (PropertyUtil.getAndFinalize(getExtension().getForge().getUseCustomMixin())) { + // See mixin remapper service in forge-runtime + launchConfig + .property("architectury.mixinRemapper.sourceNamespace", intermediateNs) + .property("architectury.mixinRemapper.mappingsPath", mappingsPath); + } else { + launchConfig.property("net.minecraftforge.gradle.GradleStart.srg.srg-mcp", getExtension().getMappingConfiguration().srgToNamedSrg.toAbsolutePath().toString()); + } } Set mixinConfigs = PropertyUtil.getAndFinalize(getExtension().getForge().getMixinConfigs());