Migrate fully to mapping-io + Add comments about transitive access widners to generated sources (#495)

* Add comments about transitive access widners to generated sources

* Migrate fully to mapping io

* Use release version of lorenz-tiny

* Review comment
This commit is contained in:
modmuss50
2021-09-16 15:28:06 +01:00
committed by GitHub
parent d48c74161e
commit 9d9be1b842
13 changed files with 294 additions and 175 deletions

View File

@@ -24,14 +24,12 @@
package net.fabricmc.loom.task;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Set;
import com.google.common.collect.ImmutableMap;
@@ -49,15 +47,15 @@ import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.api.mappings.layered.spec.LayeredMappingSpecBuilder;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
import net.fabricmc.loom.api.mappings.layered.spec.LayeredMappingSpecBuilder;
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsDependency;
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
import net.fabricmc.loom.util.SourceRemapper;
import net.fabricmc.lorenztiny.TinyMappingsJoiner;
import net.fabricmc.mapping.tree.TinyMappingFactory;
import net.fabricmc.mapping.tree.TinyTree;
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
public class MigrateMappingsTask extends AbstractLoomTask {
private Path inputDir;
@@ -101,8 +99,8 @@ public class MigrateMappingsTask extends AbstractLoomTask {
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
try {
TinyTree currentMappings = mappingsProvider.getMappings();
TinyTree targetMappings = getMappings(mappings);
MemoryMappingTree currentMappings = mappingsProvider.getMappings();
MemoryMappingTree targetMappings = getMappings(mappings);
migrateMappings(project, extension.getMinecraftMappedProvider(), inputDir, outputDir, currentMappings, targetMappings);
project.getLogger().lifecycle(":remapped project written to " + outputDir.toAbsolutePath());
} catch (IOException e) {
@@ -149,20 +147,18 @@ public class MigrateMappingsTask extends AbstractLoomTask {
return Iterables.getOnlyElement(files);
}
private static TinyTree getMappings(File mappings) throws IOException {
Path temp = Files.createTempFile("mappings", ".tiny");
private static MemoryMappingTree getMappings(File mappings) throws IOException {
MemoryMappingTree mappingTree = new MemoryMappingTree();
try (FileSystem fileSystem = FileSystems.newFileSystem(mappings.toPath(), (ClassLoader) null)) {
Files.copy(fileSystem.getPath("mappings/mappings.tiny"), temp, StandardCopyOption.REPLACE_EXISTING);
MappingReader.read(fileSystem.getPath("mappings/mappings.tiny"), mappingTree);
}
try (BufferedReader reader = Files.newBufferedReader(temp)) {
return TinyMappingFactory.loadWithDetection(reader);
}
return mappingTree;
}
private static void migrateMappings(Project project, MinecraftMappedProvider minecraftMappedProvider,
Path inputDir, Path outputDir, TinyTree currentMappings, TinyTree targetMappings
Path inputDir, Path outputDir, MemoryMappingTree currentMappings, MemoryMappingTree targetMappings
) throws IOException {
project.getLogger().info(":joining mappings");