Skip to content

Commit

Permalink
Delete forge mods' jarjar metadata (#159)
Browse files Browse the repository at this point in the history
* Delete forge mods' jarjar metadata

* Update ZipUtils.java

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

Co-authored-by: Juuz <[email protected]>

---------

Co-authored-by: Juuz <[email protected]>
  • Loading branch information
shedaniel and Juuxel committed Sep 4, 2023
1 parent 7a26b37 commit fce31a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ private String describeConfiguration(Configuration configuration) {
}

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.
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/fabricmc/loom/util/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public static void replace(Path zip, String path, byte[] bytes) throws IOExcepti
}
}

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());
}
Expand Down

0 comments on commit fce31a4

Please sign in to comment.