Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete forge mods' jarjar metadata #159

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading