From f298a566099cd01b70e1976c5ce09cdd2dfff12d Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 2 Dec 2024 12:44:33 -0800 Subject: [PATCH] Set compression level Minor cleanups Bump ASM --- settings.gradle | 14 +++++++------- src/main/java/net/minecraftforge/fart/Main.java | 1 + .../fart/internal/EnhancedClassRemapper.java | 1 + .../minecraftforge/fart/internal/RenamerImpl.java | 15 +++++++++++---- .../fart/internal/RenamingTransformer.java | 1 - 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/settings.gradle b/settings.gradle index 7f93a26..1950078 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,17 +20,17 @@ dependencyResolutionManagement { library('nulls', 'org.jetbrains:annotations:24.0.1') library('powermock', 'org.powermock:powermock-core:2.0.9') - version('asm', '9.7') + version('asm', '9.7.1') library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm') library('asm-commons', 'org.ow2.asm', 'asm-commons').versionRef('asm') library('asm-tree', 'org.ow2.asm', 'asm-tree' ).versionRef('asm') bundle('asm', ['asm', 'asm-commons', 'asm-tree']) - - version('junit', '5.10.1') - library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') - library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') - library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.1') - bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher']) + + version('junit', '5.10.1') + library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') + library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') + library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.1') + bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher']) } } } diff --git a/src/main/java/net/minecraftforge/fart/Main.java b/src/main/java/net/minecraftforge/fart/Main.java index 2ed37f3..f1c7afe 100644 --- a/src/main/java/net/minecraftforge/fart/Main.java +++ b/src/main/java/net/minecraftforge/fart/Main.java @@ -61,6 +61,7 @@ public static void main(String[] args) throws IOException { }; if (options.has(logO)) { PrintStream out = System.out; + @SuppressWarnings("resource") PrintStream file = new PrintStream(new FileOutputStream(options.valueOf(logO))); log = ln -> { if (!ln.isEmpty()) { diff --git a/src/main/java/net/minecraftforge/fart/internal/EnhancedClassRemapper.java b/src/main/java/net/minecraftforge/fart/internal/EnhancedClassRemapper.java index b499535..00a0024 100644 --- a/src/main/java/net/minecraftforge/fart/internal/EnhancedClassRemapper.java +++ b/src/main/java/net/minecraftforge/fart/internal/EnhancedClassRemapper.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; + import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; diff --git a/src/main/java/net/minecraftforge/fart/internal/RenamerImpl.java b/src/main/java/net/minecraftforge/fart/internal/RenamerImpl.java index 4538910..3193518 100644 --- a/src/main/java/net/minecraftforge/fart/internal/RenamerImpl.java +++ b/src/main/java/net/minecraftforge/fart/internal/RenamerImpl.java @@ -11,7 +11,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -37,6 +36,7 @@ class RenamerImpl implements Renamer { private final List classProviders; private final int threads; private final Consumer logger; + @SuppressWarnings("unused") private final Consumer debug; private boolean setup = false; private ClassProvider libraryClasses; @@ -70,12 +70,16 @@ public void run(File input, File output) { if (!this.setup) this.setup(); - input = Objects.requireNonNull(input).getAbsoluteFile(); - output = Objects.requireNonNull(output).getAbsoluteFile(); - + if (input == null) + throw new IllegalArgumentException("input argument can't be null"); + if (output == null) + throw new IllegalArgumentException("output argument can't be null"); if (!input.exists()) throw new IllegalArgumentException("Input file not found: " + input.getAbsolutePath()); + input = input.getAbsoluteFile(); + output = output.getAbsoluteFile(); + logger.accept("Reading Input: " + input.getAbsolutePath()); // Read everything from the input jar! List oldEntries = new ArrayList<>(); @@ -159,6 +163,9 @@ else if (name.equals(MANIFEST_NAME)) logger.accept("Writing Output: " + output.getAbsolutePath()); try (FileOutputStream fos = new FileOutputStream(output); ZipOutputStream zos = new ZipOutputStream(fos)) { + // Explicitly set compression level because of potential differences based on environment. + // See https://github.com/MinecraftForge/JarSplitter/pull/2 + zos.setLevel(6); for (Entry e : newEntries) { String name = e.getName(); diff --git a/src/main/java/net/minecraftforge/fart/internal/RenamingTransformer.java b/src/main/java/net/minecraftforge/fart/internal/RenamingTransformer.java index 58e7888..ee7874f 100644 --- a/src/main/java/net/minecraftforge/fart/internal/RenamingTransformer.java +++ b/src/main/java/net/minecraftforge/fart/internal/RenamingTransformer.java @@ -5,7 +5,6 @@ package net.minecraftforge.fart.internal; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set;