mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Fix aw2at tests, add Yarn 1.16 test (#45)
* Fix aw2at tests * Clean up the code anyway because it was messy * Normalise everything to LF * ...really, another typo? * Import ordering * Add Yarn aw2at test * wow bad os
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -67,6 +68,7 @@ import dev.architectury.tinyremapper.TinyUtils;
|
||||
import dev.architectury.tinyremapper.extension.mixin.MixinExtension;
|
||||
import org.cadixdev.at.AccessTransformSet;
|
||||
import org.cadixdev.at.io.AccessTransformFormats;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
@@ -99,6 +101,7 @@ import net.fabricmc.loom.configuration.accesswidener.AccessWidenerJarProcessor;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
import net.fabricmc.loom.util.LfWriter;
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
import net.fabricmc.loom.util.TinyRemapperMappingsHelper;
|
||||
import net.fabricmc.loom.util.ZipReprocessorUtil;
|
||||
@@ -494,8 +497,8 @@ public class RemapJarTask extends Jar {
|
||||
throw new NoSuchFileException("Could not find AW '" + aw + "' to convert into AT!");
|
||||
}
|
||||
|
||||
try (InputStream in = Files.newInputStream(awPath)) {
|
||||
at.merge(Aw2At.toAccessTransformSet(in));
|
||||
try (BufferedReader reader = Files.newBufferedReader(awPath, StandardCharsets.UTF_8)) {
|
||||
at.merge(Aw2At.toAccessTransformSet(reader));
|
||||
}
|
||||
|
||||
Files.delete(awPath);
|
||||
@@ -503,10 +506,13 @@ public class RemapJarTask extends Jar {
|
||||
|
||||
LoomGradleExtension extension = LoomGradleExtension.get(getProject());
|
||||
TinyTree mappings = extension.shouldGenerateSrgTiny() ? extension.getMappingsProvider().getMappingsWithSrg() : extension.getMappingsProvider().getMappings();
|
||||
TinyMappingsReader reader = new TinyMappingsReader(mappings, fromM.get(), toM.get());
|
||||
at = at.remap(reader.read());
|
||||
|
||||
try (Writer writer = Files.newBufferedWriter(atPath)) {
|
||||
try (TinyMappingsReader reader = new TinyMappingsReader(mappings, fromM.get(), toM.get())) {
|
||||
MappingSet mappingSet = reader.read();
|
||||
at = at.remap(mappingSet);
|
||||
}
|
||||
|
||||
try (Writer writer = new LfWriter(Files.newBufferedWriter(atPath))) {
|
||||
AccessTransformFormats.FML.write(writer, at);
|
||||
}
|
||||
}
|
||||
|
||||
43
src/main/java/net/fabricmc/loom/util/LfWriter.java
Normal file
43
src/main/java/net/fabricmc/loom/util/LfWriter.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2021 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 java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* A {@link BufferedWriter} that writes {@code \n} (LF) instead of {@link System#lineSeparator()}.
|
||||
*/
|
||||
public class LfWriter extends BufferedWriter {
|
||||
public LfWriter(Writer out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newLine() throws IOException {
|
||||
write('\n');
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,6 @@ package net.fabricmc.loom.util.aw2at;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.cadixdev.at.AccessChange;
|
||||
@@ -82,27 +79,25 @@ public final class Aw2At {
|
||||
remapJar.getAtAccessWideners().addAll(extension.getForge().getExtraAccessWideners());
|
||||
}
|
||||
|
||||
public static AccessTransformSet toAccessTransformSet(InputStream in) throws IOException {
|
||||
public static AccessTransformSet toAccessTransformSet(BufferedReader reader) throws IOException {
|
||||
AccessTransformSet atSet = AccessTransformSet.create();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||
new AccessWidenerReader(new AccessWidenerReader.Visitor() {
|
||||
@Override
|
||||
public void visitClass(String name, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(name).merge(toAt(access));
|
||||
}
|
||||
new AccessWidenerReader(new AccessWidenerReader.Visitor() {
|
||||
@Override
|
||||
public void visitClass(String name, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(name).merge(toAt(access));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethod(String owner, String name, String descriptor, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(owner).mergeMethod(MethodSignature.of(name, descriptor), toAt(access));
|
||||
}
|
||||
@Override
|
||||
public void visitMethod(String owner, String name, String descriptor, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(owner).mergeMethod(MethodSignature.of(name, descriptor), toAt(access));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitField(String owner, String name, String descriptor, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(owner).mergeField(name, toAt(access));
|
||||
}
|
||||
}).read(reader);
|
||||
}
|
||||
@Override
|
||||
public void visitField(String owner, String name, String descriptor, AccessWidenerReader.AccessType access) {
|
||||
atSet.getOrCreateClass(owner).mergeField(name, toAt(access));
|
||||
}
|
||||
}).read(reader);
|
||||
|
||||
return atSet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user