Delete forge mods' jarjar metadata (#159)

* Delete forge mods' jarjar metadata

* Update ZipUtils.java

* Update src/main/java/net/fabricmc/loom/util/ZipUtils.java

Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>

---------

Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
shedaniel
2023-09-05 03:30:13 +08:00
committed by GitHub
parent 7a26b375e0
commit fce31a4f1d
2 changed files with 12 additions and 0 deletions

View File

@@ -121,6 +121,12 @@ public class ModProcessor {
}
private void stripNestedJars(Path path) {
try {
ZipUtils.deleteIfExists(path, "META-INF/jarjar/metadata.json");
} catch (IOException e) {
throw new UncheckedIOException("Failed to strip nested jars from %s".formatted(path), e);
}
if (!ZipUtils.contains(path, "fabric.mod.json")) {
if (ZipUtils.contains(path, "quilt.mod.json")) {
// Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.

View File

@@ -184,6 +184,12 @@ public class ZipUtils {
}
}
public static void deleteIfExists(Path zip, String path) throws IOException {
try (FileSystemUtil.Delegate fs = FileSystemUtil.getJarFileSystem(zip, false)) {
Files.deleteIfExists(fs.getPath(path));
}
}
public static int transformString(Path zip, Collection<Pair<String, UnsafeUnaryOperator<String>>> transforms) throws IOException {
return transformString(zip, transforms.stream());
}