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 String loaderLaunchMethod;
public boolean remapMod = true; public boolean remapMod = true;
public boolean autoGenIDERuns = true; public boolean autoGenIDERuns = true;
public boolean extractJars = false;
private List<File> unmappedModsBuilt = new ArrayList<>(); private List<File> unmappedModsBuilt = new ArrayList<>();

View File

@ -62,11 +62,16 @@ public class ModProcessor {
} }
remapJar(input, output, project); remapJar(input, output, project);
readInstallerJson(input, project); readInstallerJson(input, project);
try { //Enable this if you want your nested jars to be extracted, this will extract **all** jars
handleNestedJars(input, project); if(project.getExtensions().getByType(LoomGradleExtension.class).extractJars){
} catch (IOException e) { try {
throw new RuntimeException("Failed to handle nested jar", e); 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 { private static void handleNestedJars(File input, Project project) throws IOException {
@ -112,8 +117,13 @@ public class ModProcessor {
throw new RuntimeException("Failed to find processed nested jar"); 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. //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 @Override
protected String transform(ZipEntry zipEntry, String input) throws IOException { protected String transform(ZipEntry zipEntry, String input) throws IOException {
JsonObject json = GSON.fromJson(input, JsonObject.class); JsonObject json = GSON.fromJson(input, JsonObject.class);
@ -121,9 +131,6 @@ public class ModProcessor {
return GSON.toJson(json); 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){ private static void remapJar(File input, File output, Project project){