From 9bcce94d5ad02716cdcb0350345c3e78c47d57b7 Mon Sep 17 00:00:00 2001 From: modmuss Date: Sun, 26 Jan 2025 14:02:16 +0000 Subject: [PATCH] Update to Mapping-IO 0.7.0 & Tiny Remapper 0.11 (#1245) * Update to Mapping-IO 0.7.0 * Update to Mapping-IO 0.7.1 * Revert changes * Update tiny remapper * Fix invalid tiny v2 header. --- gradle/libs.versions.toml | 4 +- .../loom/configuration/mods/ModProcessor.java | 3 +- .../NoOpIntermediateMappingsProvider.java | 2 +- .../minecraft/SingleJarMinecraftProvider.java | 3 +- .../loom/task/ValidateAccessWidenerTask.java | 3 +- .../task/service/TinyRemapperService.java | 3 +- .../loom/util/TinyRemapperHelper.java | 2 +- .../loom/util/TinyRemapperLoggerAdapter.java | 57 +++++++++++++++++++ 8 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 src/main/java/net/fabricmc/loom/util/TinyRemapperLoggerAdapter.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23f5f1369..8be092fce 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,9 +6,9 @@ gson = "2.10.1" guava = "33.0.0-jre" stitch = "0.6.2" -tiny-remapper = "0.10.4" +tiny-remapper = "0.11.0" access-widener = "2.1.0" -mapping-io = "0.6.1" +mapping-io = "0.7.1" lorenz-tiny = "4.0.2" mercury = "0.4.2" loom-native = "0.2.0" diff --git a/src/main/java/net/fabricmc/loom/configuration/mods/ModProcessor.java b/src/main/java/net/fabricmc/loom/configuration/mods/ModProcessor.java index b9e7b8cc1..32f5f66d7 100644 --- a/src/main/java/net/fabricmc/loom/configuration/mods/ModProcessor.java +++ b/src/main/java/net/fabricmc/loom/configuration/mods/ModProcessor.java @@ -55,6 +55,7 @@ import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Pair; import net.fabricmc.loom.util.TinyRemapperHelper; +import net.fabricmc.loom.util.TinyRemapperLoggerAdapter; import net.fabricmc.loom.util.ZipUtils; import net.fabricmc.loom.util.kotlin.KotlinClasspathService; import net.fabricmc.loom.util.kotlin.KotlinRemapperClassloader; @@ -139,7 +140,7 @@ private void remapJars(List remapList) throws IOException { knownIndyBsms.addAll(modDependency.getMetadata().knownIdyBsms()); } - TinyRemapper.Builder builder = TinyRemapper.newRemapper() + TinyRemapper.Builder builder = TinyRemapper.newRemapper(TinyRemapperLoggerAdapter.INSTANCE) .withKnownIndyBsm(knownIndyBsms) .withMappings(TinyRemapperHelper.create(mappingConfiguration.getMappingsService(project, serviceFactory).getMappingTree(), fromM, toM, false)) .renameInvalidLocals(false) diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/NoOpIntermediateMappingsProvider.java b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/NoOpIntermediateMappingsProvider.java index d198baf91..f1c6b997d 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/NoOpIntermediateMappingsProvider.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/NoOpIntermediateMappingsProvider.java @@ -38,7 +38,7 @@ */ public abstract class NoOpIntermediateMappingsProvider extends IntermediateMappingsProvider { private static final String HEADER_OFFICIAL_MERGED = "tiny\t2\t0\tofficial\tintermediary"; - private static final String HEADER_OFFICIAL_LEGACY_MERGED = "tiny\t2\t0\tintermediary\tclientOfficial\tserverOfficial\t"; + private static final String HEADER_OFFICIAL_LEGACY_MERGED = "tiny\t2\t0\tintermediary\tclientOfficial\tserverOfficial"; @Override public void provide(Path tinyMappings) throws IOException { diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/SingleJarMinecraftProvider.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/SingleJarMinecraftProvider.java index 76b065648..c96564fa7 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/SingleJarMinecraftProvider.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/SingleJarMinecraftProvider.java @@ -32,6 +32,7 @@ import net.fabricmc.loom.configuration.ConfigContext; import net.fabricmc.loom.configuration.providers.BundleMetadata; import net.fabricmc.loom.util.Constants; +import net.fabricmc.loom.util.TinyRemapperLoggerAdapter; import net.fabricmc.tinyremapper.NonClassCopyMode; import net.fabricmc.tinyremapper.OutputConsumerPath; import net.fabricmc.tinyremapper.TinyRemapper; @@ -94,7 +95,7 @@ public void provide() throws Exception { TinyRemapper remapper = null; try { - remapper = TinyRemapper.newRemapper().build(); + remapper = TinyRemapper.newRemapper(TinyRemapperLoggerAdapter.INSTANCE).build(); Files.deleteIfExists(minecraftEnvOnlyJar); diff --git a/src/main/java/net/fabricmc/loom/task/ValidateAccessWidenerTask.java b/src/main/java/net/fabricmc/loom/task/ValidateAccessWidenerTask.java index 08a46c7c3..bc2f2d73e 100644 --- a/src/main/java/net/fabricmc/loom/task/ValidateAccessWidenerTask.java +++ b/src/main/java/net/fabricmc/loom/task/ValidateAccessWidenerTask.java @@ -46,6 +46,7 @@ import net.fabricmc.accesswidener.AccessWidenerVisitor; import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.api.mappings.layered.MappingsNamespace; +import net.fabricmc.loom.util.TinyRemapperLoggerAdapter; import net.fabricmc.tinyremapper.TinyRemapper; import net.fabricmc.tinyremapper.api.TrEnvironment; @@ -70,7 +71,7 @@ public ValidateAccessWidenerTask() { @TaskAction public void run() { - final TinyRemapper tinyRemapper = TinyRemapper.newRemapper().build(); + final TinyRemapper tinyRemapper = TinyRemapper.newRemapper(TinyRemapperLoggerAdapter.INSTANCE).build(); for (File file : getTargetJars().getFiles()) { tinyRemapper.readClassPath(file.toPath()); diff --git a/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java b/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java index 7f0ae8d13..21752ea60 100644 --- a/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java +++ b/src/main/java/net/fabricmc/loom/task/service/TinyRemapperService.java @@ -54,6 +54,7 @@ import net.fabricmc.loom.extension.RemapperExtensionHolder; import net.fabricmc.loom.task.AbstractRemapJarTask; import net.fabricmc.loom.util.Constants; +import net.fabricmc.loom.util.TinyRemapperLoggerAdapter; import net.fabricmc.loom.util.kotlin.KotlinClasspathService; import net.fabricmc.loom.util.kotlin.KotlinRemapperClassloader; import net.fabricmc.loom.util.service.Service; @@ -130,7 +131,7 @@ public TinyRemapperService(Options options, ServiceFactory serviceFactory) { } private TinyRemapper createTinyRemapper() { - TinyRemapper.Builder builder = TinyRemapper.newRemapper() + TinyRemapper.Builder builder = TinyRemapper.newRemapper(TinyRemapperLoggerAdapter.INSTANCE) .withKnownIndyBsm(Set.copyOf(getOptions().getKnownIndyBsms().get())); for (MappingsService.Options options : getOptions().getMappings().get()) { diff --git a/src/main/java/net/fabricmc/loom/util/TinyRemapperHelper.java b/src/main/java/net/fabricmc/loom/util/TinyRemapperHelper.java index 4024d4bfc..4482aa9db 100644 --- a/src/main/java/net/fabricmc/loom/util/TinyRemapperHelper.java +++ b/src/main/java/net/fabricmc/loom/util/TinyRemapperHelper.java @@ -74,7 +74,7 @@ public static TinyRemapper getTinyRemapper(Project project, ServiceFactory servi int intermediaryNsId = mappingTree.getNamespaceId(MappingsNamespace.INTERMEDIARY.toString()); - TinyRemapper.Builder builder = TinyRemapper.newRemapper() + TinyRemapper.Builder builder = TinyRemapper.newRemapper(TinyRemapperLoggerAdapter.INSTANCE) .withMappings(create(mappingTree, fromM, toM, true)) .withMappings(out -> JSR_TO_JETBRAINS.forEach(out::acceptClass)) .renameInvalidLocals(true) diff --git a/src/main/java/net/fabricmc/loom/util/TinyRemapperLoggerAdapter.java b/src/main/java/net/fabricmc/loom/util/TinyRemapperLoggerAdapter.java new file mode 100644 index 000000000..8bc9872d1 --- /dev/null +++ b/src/main/java/net/fabricmc/loom/util/TinyRemapperLoggerAdapter.java @@ -0,0 +1,57 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2025 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.fabricmc.tinyremapper.api.TrLogger; + +public final class TinyRemapperLoggerAdapter implements TrLogger { + public static final TinyRemapperLoggerAdapter INSTANCE = new TinyRemapperLoggerAdapter(); + + private static final Logger LOGGER = LoggerFactory.getLogger("TinyRemapper"); + + private TinyRemapperLoggerAdapter() { + } + + @Override + public void log(Level level, String message) { + switch (level) { + case ERROR: + LOGGER.error(message); + break; + case WARN: + LOGGER.warn(message); + break; + case INFO: + LOGGER.info(message); + break; + case DEBUG: + LOGGER.debug(message); + break; + } + } +}