Dont expand out nested jars can be enabled if wanted. Will still strip the jars from the mod json

dev/0.11
modmuss50 2019-04-08 10:50:30 +01:00
parent 0206a4c59b
commit f672b815c4
2 changed files with 16 additions and 8 deletions

View File

@ -47,6 +47,7 @@ public class LoomGradleExtension {
public String loaderLaunchMethod;
public boolean remapMod = true;
public boolean autoGenIDERuns = true;
public boolean extractJars = false;
private List<File> unmappedModsBuilt = new ArrayList<>();

View File

@ -62,12 +62,17 @@ public class ModProcessor {
}
remapJar(input, output, project);
readInstallerJson(input, project);
//Enable this if you want your nested jars to be extracted, this will extract **all** jars
if(project.getExtensions().getByType(LoomGradleExtension.class).extractJars){
try {
handleNestedJars(input, project);
} catch (IOException e) {
throw new RuntimeException("Failed to handle nested jar", e);
}
}
//Always strip the nested jars
stripNestedJars(output);
}
private static void handleNestedJars(File input, Project project) throws IOException {
JarFile jarFile = new JarFile(input);
@ -112,8 +117,13 @@ public class ModProcessor {
throw new RuntimeException("Failed to find processed nested jar");
}
//Add the project right onto the remapped mods, hopefully this works
project.getDependencies().add(Constants.COMPILE_MODS_MAPPED, project.files(remappedFile));
}
private static void stripNestedJars(File file){
//Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.
ZipUtil.transformEntries(remappedFile, new ZipEntryTransformerEntry[]{(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() {
ZipUtil.transformEntries(file, new ZipEntryTransformerEntry[]{(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() {
@Override
protected String transform(ZipEntry zipEntry, String input) throws IOException {
JsonObject json = GSON.fromJson(input, JsonObject.class);
@ -121,9 +131,6 @@ public class ModProcessor {
return GSON.toJson(json);
}
}))});
//Add the project right onto the remapped mods, hopefully this works
project.getDependencies().add(Constants.COMPILE_MODS_MAPPED, project.files(remappedFile));
}
private static void remapJar(File input, File output, Project project){