Skip to content

Commit

Permalink
Post merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Dec 13, 2024
1 parent d4aa9c9 commit 1ae3f80
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 328 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ tasks.register('proguardJar', proguard.gradle.ProGuardTask) {
}
libraryjars(configurations.compileClasspath)

injars shadowJar.archiveFile
injars(["filter":"!META-INF/maven/**/*"], shadowJar.archiveFile)
outjars proguardFile
configuration file("proguard.conf")
}
Expand Down
5 changes: 4 additions & 1 deletion proguard.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
-dontobfuscate
-dontoptimize

-keep class net.neoforged.installertools.cli.ConsoleTool { *; }

-keep class net.neoforged.installertools.cli.Main {
public static void main(java.lang.String[]);
}
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pluginManagement {
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
}

dependencyResolutionManagement {
versionCatalogs {
libs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import com.google.gson.GsonBuilder;
import net.neoforged.installertools.tasks.Tasks;

public class ConsoleTool {
public static final Gson GSON = new GsonBuilder().create();

public class Main {
public static void main(String[] args) throws IOException {
Tasks task = null;
String valid = Arrays.stream(Tasks.class.getEnumConstants()).map(Enum::name).collect(Collectors.joining(", "));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* InstallerTools
* Copyright (c) 2019-2024.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.neoforged.installertools.tasks;

import net.neoforged.installertools.binarypatcher.ConsoleTool;

import java.io.IOException;

public class BinaryPatcher extends Task {
@Override
public void process(String[] args) throws IOException {
ConsoleTool.main(args);
}
}
6 changes: 4 additions & 2 deletions src/main/java/net/neoforged/installertools/tasks/McpData.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import net.neoforged.installertools.cli.ConsoleTool;

public class McpData extends Task {
public static final Gson GSON = new GsonBuilder().create();

@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -75,7 +77,7 @@ public void process(String[] args) throws IOException {
error("Input zip file invalid, missing 'config.json' entry");

try (InputStream cfgStream = zip.getInputStream(config)) {
McpConfig cfg = ConsoleTool.GSON.fromJson(new InputStreamReader(zip.getInputStream(config)), McpConfig.class);
McpConfig cfg = GSON.fromJson(new InputStreamReader(cfgStream), McpConfig.class);
if (cfg.data == null)
error("Invalid mcp config, missing data map");

Expand Down
15 changes: 6 additions & 9 deletions src/main/java/net/neoforged/installertools/tasks/SplitJar.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
import net.neoforged.installertools.cli.progress.ProgressReporter;
import net.neoforged.srgutils.IMappingFile;

public class SplitJar {
public class SplitJar extends Task {
private static final OutputStream NULL_OUTPUT = new OutputStream() {
@Override public void write(int b) {}
};
private static final boolean DEBUG = Boolean.getBoolean("net.neoforged.jarsplitter.debug");
private static final ProgressManager PROGRESS = ProgressReporter.getDefault();

public static void main(String[] args) throws IOException {
@Override
public void process(String[] args) throws IOException {
TimeZone.setDefault(TimeZone.getTimeZone("GMT")); //Fix Java stupidity that causes timestamps in zips to depend on user's timezone!
OptionParser parser = new OptionParser();
// Shared arguments
Expand Down Expand Up @@ -172,11 +173,11 @@ private static void writeCache(File file, String inputSha, String srgSha) throws
Files.write(cacheFile.toPath(), cache);
}

private static File checkOutput(String name, File file, String inputSha, String srgSha) throws IOException {
private File checkOutput(String name, File file, String inputSha, String srgSha) throws IOException {
return checkOutput(name, file, inputSha, srgSha, null);
}

private static File checkOutput(String name, File file, String inputSha, String srgSha, String extra) throws IOException {
private File checkOutput(String name, File file, String inputSha, String srgSha, String extra) throws IOException {
if (file == null) return null;

file = file.getCanonicalFile();
Expand All @@ -202,11 +203,7 @@ private static File checkOutput(String name, File file, String inputSha, String
return file;
}

public static void log(String message) {
System.out.println(message);
}

public static void debug(String message) {
public void debug(String message) {
if (DEBUG) {
log(message);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/neoforged/installertools/tasks/Tasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public enum Tasks {
DOWNLOAD_MOJMAPS(DownloadMojmaps::new),
EXTRACT_FILES(ExtractFiles::new),
BUNDLER_EXTRACT(BundlerExtract::new),
BINARY_PATCHER(BinaryPatcher::new),
SPLIT_JAR(SplitJar::new)
;

private Supplier<? extends Task> supplier;
Expand Down
166 changes: 0 additions & 166 deletions src/main/java/net/neoforged/installertools/tasks/ZipInject.java

This file was deleted.

Loading

0 comments on commit 1ae3f80

Please sign in to comment.