Forgot to commit fix merge conflicts

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel
2021-10-27 12:04:17 +08:00
parent decdb1fd85
commit 70d4a1d691
17 changed files with 108 additions and 154 deletions

View File

@@ -91,7 +91,7 @@ dependencies {
}
// tinyfile management
implementation ('dev.architectury:tiny-remapper:1.4.12')
implementation ('dev.architectury:tiny-remapper:1.5.15')
implementation 'net.fabricmc:access-widener:2.0.1'
implementation 'net.fabricmc:mapping-io:0.2.1'

View File

@@ -24,6 +24,8 @@
package net.fabricmc.loom.configuration.mods;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -41,11 +43,13 @@ import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import com.google.common.base.Stopwatch;
import com.google.gson.JsonObject;
import dev.architectury.tinyremapper.InputTag;
import dev.architectury.tinyremapper.NonClassCopyMode;
import dev.architectury.tinyremapper.OutputConsumerPath;
import dev.architectury.tinyremapper.TinyRemapper;
import org.gradle.api.Project;
@@ -62,11 +66,11 @@ import net.fabricmc.loom.configuration.processors.dependency.ModDependencyInfo;
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.LoggerFilter;
import net.fabricmc.loom.util.TinyRemapperHelper;
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.loom.util.srg.AtRemapper;
import net.fabricmc.tinyremapper.NonClassCopyMode;
import net.fabricmc.loom.util.srg.CoreModClassRemapper;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
@@ -102,7 +106,8 @@ public class ModProcessor {
}
private static void stripNestedJars(File file) {
if (!ZipUtil.containsEntry(file, "fabric.mod.json")) return;
if (!ZipUtils.contains(file.toPath(), "fabric.mod.json")) return;
// Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.
try {
ZipUtils.transformJson(JsonObject.class, file.toPath(), Map.of("fabric.mod.json", json -> {
@@ -226,25 +231,35 @@ public class ModProcessor {
AtRemapper.remap(project.getLogger(), info.getRemappedOutput().toPath(), mappings);
CoreModClassRemapper.remapJar(info.getRemappedOutput().toPath(), mappings, project.getLogger());
if (ZipUtil.containsEntry(info.getRemappedOutput(), "META-INF/MANIFEST.MF")) {
ZipUtil.transformEntry(info.getRemappedOutput(), "META-INF/MANIFEST.MF", (in, zipEntry, out) -> {
Manifest manifest = new Manifest(in);
fixManifest(manifest);
out.putNextEntry(new ZipEntry(zipEntry.getName()));
manifest.write(out);
out.closeEntry();
});
}
ZipUtils.transform(info.getRemappedOutput().toPath(), Map.of("META-INF/MANIFEST.MF", bytes -> {
Manifest manifest = new Manifest(new ByteArrayInputStream(bytes));
fixManifest(manifest);
ByteArrayOutputStream out = new ByteArrayOutputStream();
manifest.write(out);
return out.toByteArray();
}));
List<String> filesToRemove = new ArrayList<>();
ZipUtil.iterate(info.getRemappedOutput(), (in, zipEntry) -> {
if (zipEntry.getName().toLowerCase(Locale.ROOT).endsWith(".rsa") || zipEntry.getName().toLowerCase(Locale.ROOT).endsWith(".sf")) {
if (zipEntry.getName().startsWith("META-INF")) {
filesToRemove.add(zipEntry.getName());
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(info.getRemappedOutput().toPath(), false);
Stream<Path> walk = Files.walk(fs.get().getPath("/"))) {
List<Path> filesToRemove = new ArrayList<>();
Iterator<Path> iterator = walk.iterator();
while (iterator.hasNext()) {
Path fsPath = iterator.next();
if (!Files.isRegularFile(fsPath)) continue;
String fileName = fsPath.toString();
if (fileName.toLowerCase(Locale.ROOT).endsWith(".rsa") || fileName.toLowerCase(Locale.ROOT).endsWith(".sf")) {
if (fileName.startsWith("META-INF")) {
filesToRemove.add(fsPath);
}
}
}
});
ZipUtil.removeEntries(info.getRemappedOutput(), filesToRemove.toArray(new String[0]));
for (Path fileToRemove : filesToRemove) {
Files.delete(fileToRemove);
}
}
}
info.finaliseRemapping();

View File

@@ -205,7 +205,7 @@ public class FieldMigratedMappingsProvider extends MappingsProviderImpl {
for (MinecraftPatchedProvider.Environment environment : MinecraftPatchedProvider.Environment.values()) {
File patchedSrgJar = environment.patchedSrgJar.apply(extension.getMappingsProvider().patchedProvider);
FileSystemUtil.FileSystemDelegate system = FileSystemUtil.getJarFileSystem(patchedSrgJar, false);
FileSystemUtil.Delegate system = FileSystemUtil.getJarFileSystem(patchedSrgJar, false);
completer.onComplete(value -> system.close());
for (Path fsPath : (Iterable<? extends Path>) Files.walk(system.get().getPath("/"))::iterator) {

View File

@@ -197,7 +197,7 @@ public class ForgeUserdevProvider extends DependencyProvider {
File output = outputs.file(input.getName() + "-alfd-transformed.jar");
Files.copy(input.toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING);
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(output, false)) {
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(output, false)) {
Path path = fs.get().getPath("META-INF/services/cpw.mods.modlauncher.api.INameMappingService");
Files.deleteIfExists(path);
}

View File

@@ -24,11 +24,8 @@
package net.fabricmc.loom.configuration.providers.forge;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
@@ -37,16 +34,14 @@ import java.util.function.Consumer;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.apache.commons.io.IOUtils;
import org.gradle.api.Project;
import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.configuration.DependencyProvider;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.ZipUtils;
public class McpConfigProvider extends DependencyProvider {
private File mcp;
private Path mcp;
private Path configJson;
private Path mappings;
private Boolean official;
@@ -62,12 +57,9 @@ public class McpConfigProvider extends DependencyProvider {
Path mcpZip = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not resolve MCPConfig")).toPath();
if (!mcp.exists() || !Files.exists(configJson) || isRefreshDeps()) {
Files.copy(mcpZip, mcp.toPath(), StandardCopyOption.REPLACE_EXISTING);
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(mcp, false)) {
Files.copy(fs.get().getPath("config.json"), configJson, StandardCopyOption.REPLACE_EXISTING);
}
if (!Files.exists(mcp) || !Files.exists(configJson) || isRefreshDeps()) {
Files.copy(mcpZip, mcp, StandardCopyOption.REPLACE_EXISTING);
Files.write(configJson, ZipUtils.unpack(mcp, "config.json"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
}
JsonObject json;
@@ -81,10 +73,10 @@ public class McpConfigProvider extends DependencyProvider {
}
private void init(String version) throws IOException {
File dir = getMinecraftProvider().dir("mcp/" + version);
mcp = new File(dir, "mcp.zip");
configJson = dir.toPath().resolve("mcp-config.json");
mappings = dir.toPath().resolve("mcp-config-mappings.txt");
Path dir = getMinecraftProvider().dir("mcp/" + version).toPath();
mcp = dir.resolve("mcp.zip");
configJson = dir.resolve("mcp-config.json");
mappings = dir.resolve("mcp-config-mappings.txt");
if (isRefreshDeps()) {
Files.deleteIfExists(mappings);
@@ -93,19 +85,17 @@ public class McpConfigProvider extends DependencyProvider {
public Path getMappings() {
if (Files.notExists(mappings)) {
if (!ZipUtil.handle(getMcp(), getMappingsPath(), (in, zipEntry) -> {
try (BufferedWriter writer = Files.newBufferedWriter(mappings, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
IOUtils.copy(in, writer, StandardCharsets.UTF_8);
}
})) {
throw new IllegalStateException("Failed to find mappings '" + getMappingsPath() + "' in " + getMcp().getAbsolutePath() + "!");
try {
Files.write(mappings, ZipUtils.unpack(getMcp(), getMappingsPath()), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) {
throw new IllegalStateException("Failed to find mappings '" + getMappingsPath() + "' in " + getMcp() + "!");
}
}
return mappings;
}
public File getMcp() {
public Path getMcp() {
return mcp;
}

View File

@@ -24,6 +24,7 @@
package net.fabricmc.loom.configuration.providers.forge;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
@@ -83,7 +84,6 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.configuration.DependencyProvider;
import net.fabricmc.loom.configuration.providers.MinecraftProviderImpl;
@@ -93,6 +93,7 @@ import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.MappingsProviderVerbose;
import net.fabricmc.loom.util.ThreadingUtils;
import net.fabricmc.loom.util.TinyRemapperHelper;
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.loom.util.function.FsPathConsumer;
import net.fabricmc.loom.util.srg.InnerClassRemapper;
import net.fabricmc.loom.util.srg.SpecialSourceExecutor;
@@ -458,26 +459,25 @@ public class MinecraftPatchedProvider extends DependencyProvider {
return getExtension().getForgeUserdevProvider().getUserdevJar();
}
private boolean isPatchedJarUpToDate(File jar) {
private boolean isPatchedJarUpToDate(File jar) throws IOException {
if (!jar.exists()) return false;
boolean[] upToDate = {false};
byte[] manifestBytes = ZipUtils.unpackNullable(jar.toPath(), "META-INF/MANIFEST.MF");
if (!ZipUtil.handle(jar, "META-INF/MANIFEST.MF", (in, zipEntry) -> {
Manifest manifest = new Manifest(in);
Attributes attributes = manifest.getMainAttributes();
String value = attributes.getValue(LOOM_PATCH_VERSION_KEY);
if (Objects.equals(value, CURRENT_LOOM_PATCH_VERSION)) {
upToDate[0] = true;
} else {
getProject().getLogger().lifecycle(":forge patched jars not up to date. current version: " + value);
}
})) {
if (manifestBytes == null) {
return false;
}
return upToDate[0];
Manifest manifest = new Manifest(new ByteArrayInputStream(manifestBytes));
Attributes attributes = manifest.getMainAttributes();
String value = attributes.getValue(LOOM_PATCH_VERSION_KEY);
if (Objects.equals(value, CURRENT_LOOM_PATCH_VERSION)) {
return true;
} else {
getProject().getLogger().lifecycle(":forge patched jars not up to date. current version: " + value);
return false;
}
}
private void accessTransformForge(Logger logger) throws Exception {
@@ -499,17 +499,14 @@ public class MinecraftPatchedProvider extends DependencyProvider {
args.add(target.getAbsolutePath());
for (File jar : ImmutableList.of(getForgeJar(), getForgeUserdevJar(), minecraftMergedPatchedSrgJar)) {
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(jar, false)) {
Path atPath = fs.get().getPath(Constants.Forge.ACCESS_TRANSFORMER_PATH);
byte[] atBytes = ZipUtils.unpackNullable(jar.toPath(), Constants.Forge.ACCESS_TRANSFORMER_PATH);
if (Files.exists(atPath)) {
File tmpFile = File.createTempFile("at-conf", ".cfg");
tmpFile.delete();
toDelete.add(tmpFile);
Files.copy(atPath, tmpFile.toPath());
args.add("--atFile");
args.add(tmpFile.getAbsolutePath());
}
if (atBytes != null) {
File tmpFile = File.createTempFile("at-conf", ".cfg");
toDelete.add(tmpFile);
Files.write(tmpFile.toPath(), atBytes, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
args.add("--atFile");
args.add(tmpFile.getAbsolutePath());
}
}
@@ -664,8 +661,8 @@ public class MinecraftPatchedProvider extends DependencyProvider {
private void walkFileSystems(File source, File target, Predicate<Path> filter, Function<FileSystem, Iterable<Path>> toWalk, FsPathConsumer action)
throws IOException {
try (FileSystemUtil.FileSystemDelegate sourceFs = FileSystemUtil.getJarFileSystem(source, false);
FileSystemUtil.FileSystemDelegate targetFs = FileSystemUtil.getJarFileSystem(target, false)) {
try (FileSystemUtil.Delegate sourceFs = FileSystemUtil.getJarFileSystem(source, false);
FileSystemUtil.Delegate targetFs = FileSystemUtil.getJarFileSystem(target, false)) {
for (Path sourceDir : toWalk.apply(sourceFs.get())) {
Path dir = sourceDir.toAbsolutePath();
if (!Files.exists(dir)) continue;
@@ -749,7 +746,7 @@ public class MinecraftPatchedProvider extends DependencyProvider {
}
public void applyLoomPatchVersion(Path target) throws IOException {
try (FileSystemUtil.FileSystemDelegate delegate = FileSystemUtil.getJarFileSystem(target, false)) {
try (FileSystemUtil.Delegate delegate = FileSystemUtil.getJarFileSystem(target, false)) {
Path manifestPath = delegate.get().getPath("META-INF/MANIFEST.MF");
Preconditions.checkArgument(Files.exists(manifestPath), "META-INF/MANIFEST.MF does not exist in patched srg jar!");

View File

@@ -41,7 +41,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
@@ -70,10 +69,10 @@ import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvid
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DeletingFileVisitor;
import net.fabricmc.loom.util.DownloadUtil;
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.loom.util.srg.MCPReader;
import net.fabricmc.loom.util.srg.SrgMerger;
import net.fabricmc.loom.util.srg.SrgNamedWriter;
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.adapter.MappingNsCompleter;
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;

View File

@@ -40,7 +40,7 @@ public record CraneMappingLayer(Path craneJar) implements MappingLayer {
@Override
public void visit(MappingVisitor visitor) throws IOException {
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(craneJar(), false)) {
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(craneJar(), false)) {
try (BufferedReader reader = Files.newBufferedReader(fs.get().getPath(TINY_FILE_NAME), StandardCharsets.UTF_8)) {
Tiny2Reader.read(reader, visitor);
}

View File

@@ -181,7 +181,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
private byte[][] inputBytes(Path input) throws IOException {
List<byte[]> inputByteList = new ArrayList<>();
try (FileSystemUtil.FileSystemDelegate inputFs = FileSystemUtil.getJarFileSystem(input, false)) {
try (FileSystemUtil.Delegate inputFs = FileSystemUtil.getJarFileSystem(input, false)) {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
for (Path path : (Iterable<? extends Path>) Files.walk(inputFs.get().getPath("/"))::iterator) {

View File

@@ -36,7 +36,6 @@ import dev.architectury.tinyremapper.InputTag;
import dev.architectury.tinyremapper.TinyRemapper;
import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.FileSystemUtil.FileSystemDelegate;
import net.fabricmc.loom.util.ThreadingUtils;
public class OutputRemappingHandler {
@@ -51,7 +50,7 @@ public class OutputRemappingHandler {
public static void remap(TinyRemapper remapper, Path assets, Path output, BiConsumer<String, byte[]> then, InputTag... inputTags) throws IOException {
Files.copy(assets, output, StandardCopyOption.REPLACE_EXISTING);
try (FileSystemDelegate system = FileSystemUtil.getJarFileSystem(output, true)) {
try (FileSystemUtil.Delegate system = FileSystemUtil.getJarFileSystem(output, true)) {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
remapper.apply((path, bytes) -> {

View File

@@ -48,7 +48,6 @@ import org.gradle.api.Project;
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.logging.configuration.ShowStacktrace;
import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.build.ModCompileRemapper;
@@ -59,6 +58,7 @@ import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.SourceRemapper;
import net.fabricmc.loom.util.ThreadingUtils;
import net.fabricmc.loom.util.TinyRemapperHelper;
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.lorenztiny.TinyMappingsReader;
public class ForgeSourcesRemapper {
@@ -71,7 +71,7 @@ public class ForgeSourcesRemapper {
}
public static void addForgeSources(Project project, Path sourcesJar) throws IOException {
try (FileSystemUtil.FileSystemDelegate delegate = FileSystemUtil.getJarFileSystem(sourcesJar, true)) {
try (FileSystemUtil.Delegate delegate = FileSystemUtil.getJarFileSystem(sourcesJar, true)) {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
provideForgeSources(project, (path, bytes) -> {
@@ -120,7 +120,7 @@ public class ForgeSourcesRemapper {
tmpOutput.delete();
tmpOutput.deleteOnExit();
try (FileSystemUtil.FileSystemDelegate delegate = FileSystemUtil.getJarFileSystem(tmpInput, true)) {
try (FileSystemUtil.Delegate delegate = FileSystemUtil.getJarFileSystem(tmpInput, true)) {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
for (Map.Entry<String, byte[]> entry : sources.entrySet()) {
@@ -156,7 +156,7 @@ public class ForgeSourcesRemapper {
tmpInput.delete();
int[] failedToRemap = {0};
try (FileSystemUtil.FileSystemDelegate delegate = FileSystemUtil.getJarFileSystem(tmpOutput, false)) {
try (FileSystemUtil.Delegate delegate = FileSystemUtil.getJarFileSystem(tmpOutput, false)) {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
for (Map.Entry<String, byte[]> entry : new HashSet<>(sources.entrySet())) {
@@ -223,10 +223,10 @@ public class ForgeSourcesRemapper {
// create tmp directory
isSrcTmp = true;
tmpInput = Files.createTempDirectory("fabric-loom-src");
ZipUtil.unpack(tmpInput1.toFile(), tmpInput.toFile());
ZipUtils.unpackAll(tmpInput1, tmpInput);
}
try (FileSystemUtil.FileSystemDelegate outputFs = FileSystemUtil.getJarFileSystem(tmpOutput, true)) {
try (FileSystemUtil.Delegate outputFs = FileSystemUtil.getJarFileSystem(tmpOutput, true)) {
Path outputFsRoot = outputFs.get().getPath("/");
mercury.rewrite(tmpInput, outputFsRoot);
} catch (Exception e) {
@@ -243,7 +243,7 @@ public class ForgeSourcesRemapper {
ThreadingUtils.TaskCompleter taskCompleter = ThreadingUtils.taskCompleter();
for (Path path : forgeInstallerSources) {
FileSystemUtil.FileSystemDelegate system = FileSystemUtil.getJarFileSystem(path, false);
FileSystemUtil.Delegate system = FileSystemUtil.getJarFileSystem(path, false);
taskCompleter.onComplete(stopwatch -> system.close());
for (Path filePath : (Iterable<? extends Path>) Files.walk(system.get().getPath("/"))::iterator) {

View File

@@ -24,9 +24,9 @@
package net.fabricmc.loom.task;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -233,22 +233,22 @@ public class RemapJarTask extends Jar {
if (!extension.isForge()) {
// Add data to the manifest
try {
int count = ZipUtils.transform(data.output, Map.of(MANIFEST_PATH, bytes -> {
var manifest = new Manifest(new ByteArrayInputStream(bytes));
var manifestConfiguration = new JarManifestConfiguration(project);
int count = ZipUtils.transform(data.output, Map.of(MANIFEST_PATH, bytes -> {
var manifest = new Manifest(new ByteArrayInputStream(bytes));
var manifestConfiguration = new JarManifestConfiguration(project);
manifestConfiguration.configure(manifest);
manifest.getMainAttributes().putValue("Fabric-Mapping-Namespace", toM);
manifestConfiguration.configure(manifest);
manifest.getMainAttributes().putValue("Fabric-Mapping-Namespace", toM);
ByteArrayOutputStream out = new ByteArrayOutputStream();
manifest.write(out);
return out.toByteArray();
}));
ByteArrayOutputStream out = new ByteArrayOutputStream();
manifest.write(out);
return out.toByteArray();
}));
Preconditions.checkState(count > 0, "Did not transform any jar manifest");
} catch (IOException e) {
throw new UncheckedIOException("Failed to transform jar manifest", e);
}
Preconditions.checkState(count > 0, "Did not transform any jar manifest");
} catch (IOException e) {
throw new UncheckedIOException("Failed to transform jar manifest", e);
}
}
if (isReproducibleFileOrder() || !isPreserveFileTimestamps()) {
@@ -362,7 +362,7 @@ public class RemapJarTask extends Jar {
AccessTransformSet at = AccessTransformSet.create();
File jar = getArchiveFile().get().getAsFile();
try (FileSystemUtil.FileSystemDelegate fileSystem = FileSystemUtil.getJarFileSystem(jar, false)) {
try (FileSystemUtil.Delegate fileSystem = FileSystemUtil.getJarFileSystem(jar, false)) {
FileSystem fs = fileSystem.get();
Path atPath = fs.getPath(Constants.Forge.ACCESS_TRANSFORMER_PATH);

View File

@@ -32,6 +32,8 @@ import java.nio.file.Files;
import javax.inject.Inject;
import dev.architectury.tinyremapper.TinyRemapper;
import dev.architectury.tinyremapper.api.TrEnvironment;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputFile;
@@ -42,8 +44,6 @@ import net.fabricmc.accesswidener.AccessWidenerFormatException;
import net.fabricmc.accesswidener.AccessWidenerReader;
import net.fabricmc.accesswidener.AccessWidenerVisitor;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.api.TrEnvironment;
public abstract class ValidateAccessWidenerTask extends DefaultTask {
@SkipWhenEmpty

View File

@@ -1,45 +0,0 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2020-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.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* Working with jars.
*
* @author Juuz
*/
public final class JarUtil {
public static void extractFile(File jar, String filePath, File target) throws IOException {
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(jar, false)) {
Path targetPath = target.toPath();
Files.deleteIfExists(targetPath);
Files.copy(fs.get().getPath(filePath), targetPath);
}
}
}

View File

@@ -102,8 +102,8 @@ public final class TinyRemapperHelper {
}
builder.invalidLvNamePattern(MC_LV_PATTERN);
builder.inferNameFromSameLvIndex(true)
.extraPreApplyVisitor((cls, next) -> {
builder.inferNameFromSameLvIndex(true);
builder.extraPreApplyVisitor((cls, next) -> {
if (fixRecords && !cls.isRecord() && "java/lang/Record".equals(cls.getSuperName()) && mappings.getValue() != null) {
return new RecordComponentFixVisitor(next, mappings.getValue(), mappings.getValue().getNamespaceId(MappingsNamespace.INTERMEDIARY.toString()));
}

View File

@@ -38,7 +38,6 @@ import com.google.common.collect.HashBiMap;
import dev.architectury.tinyremapper.IMappingProvider;
import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.FileSystemUtil.FileSystemDelegate;
import net.fabricmc.mappingio.tree.MappingTree;
public class InnerClassRemapper {
@@ -51,7 +50,7 @@ public class InnerClassRemapper {
public static Set<String> readClassNames(Path jar) {
Set<String> set = new HashSet<>();
try (FileSystemDelegate system = FileSystemUtil.getJarFileSystem(jar, false)) {
try (FileSystemUtil.Delegate system = FileSystemUtil.getJarFileSystem(jar, false)) {
Iterator<Path> iterator = Files.walk(system.get().getPath("/")).iterator();
while (iterator.hasNext()) {

View File

@@ -70,8 +70,8 @@ public class SpecialSourceExecutor {
Stopwatch stopwatch = Stopwatch.createStarted();
try (FileSystemUtil.FileSystemDelegate output = FileSystemUtil.getJarFileSystem(stripped, true)) {
try (FileSystemUtil.FileSystemDelegate fs = FileSystemUtil.getJarFileSystem(officialJar, false)) {
try (FileSystemUtil.Delegate output = FileSystemUtil.getJarFileSystem(stripped, true)) {
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(officialJar, false)) {
ThreadingUtils.TaskCompleter completer = ThreadingUtils.taskCompleter();
for (Path path : (Iterable<? extends Path>) Files.walk(fs.get().getPath("/"))::iterator) {