add toggle to disable jar nesting in RemapJar tasks

dev/0.11
Adrian Siekierka 2019-04-22 00:41:28 +02:00
parent 221fcf2f51
commit 6a7a00c426
2 changed files with 17 additions and 9 deletions

View File

@ -33,25 +33,31 @@ import java.io.File;
public class RemapJar extends DefaultLoomTask { public class RemapJar extends DefaultLoomTask {
public File jar; public File jar;
public File backupTo; public File destination;
public boolean nestJar;
@Input @Input
public File getJar() { public File getJar() {
return jar; return jar;
} }
@Input
public boolean isNestJar() {
return nestJar;
}
@OutputFile @OutputFile
public File getBackupTo() { public File getDestination() {
if (backupTo == null) { if (destination == null) {
String s = jar.getAbsolutePath(); String s = jar.getAbsolutePath();
return new File(s.substring(0, s.length() - 4) + "-dev.jar"); return new File(s.substring(0, s.length() - 4) + "-dev.jar");
} }
return backupTo; return destination;
} }
@TaskAction @TaskAction
public void remap() { public void remap() {
ModRemapper.remap(this); ModRemapper.remap(this, nestJar);
} }
} }

View File

@ -42,7 +42,7 @@ import java.util.List;
public class ModRemapper { public class ModRemapper {
public static void remap(RemapJar task) { public static void remap(RemapJar task, boolean nest) {
Project project = task.getProject(); Project project = task.getProject();
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
@ -70,7 +70,7 @@ public class ModRemapper {
File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar"); File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar");
Path modJarOutputPath = modJarOutput.toPath(); Path modJarOutputPath = modJarOutput.toPath();
File modJarUnmappedCopy = task.getBackupTo(); File modJarUnmappedCopy = task.getDestination();
if (modJarUnmappedCopy.exists()) { if (modJarUnmappedCopy.exists()) {
modJarUnmappedCopy.delete(); modJarUnmappedCopy.delete();
} }
@ -107,9 +107,11 @@ public class ModRemapper {
project.getLogger().debug("Transformed mixin reference maps in output JAR!"); project.getLogger().debug("Transformed mixin reference maps in output JAR!");
} }
if (nest) {
if (NestedJars.addNestedJars(project, modJarOutput)) { if (NestedJars.addNestedJars(project, modJarOutput)) {
project.getLogger().debug("Added nested jar paths to mod json"); project.getLogger().debug("Added nested jar paths to mod json");
} }
}
try { try {
if (modJar.exists()) { if (modJar.exists()) {