Skip to content

Commit

Permalink
Update to Mapping-IO 0.7.0 & Tiny Remapper 0.11 (#1245)
Browse files Browse the repository at this point in the history
* Update to Mapping-IO 0.7.0

* Update to Mapping-IO 0.7.1

* Revert changes

* Update tiny remapper

* Fix invalid tiny v2 header.
  • Loading branch information
modmuss50 authored Jan 26, 2025
1 parent cb8ba8f commit 9bcce94
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,7 +140,7 @@ private void remapJars(List<ModDependency> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit 9bcce94

Please sign in to comment.