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 File jar;
public File backupTo;
public File destination;
public boolean nestJar;
@Input
public File getJar() {
return jar;
}
@Input
public boolean isNestJar() {
return nestJar;
}
@OutputFile
public File getBackupTo() {
if (backupTo == null) {
public File getDestination() {
if (destination == null) {
String s = jar.getAbsolutePath();
return new File(s.substring(0, s.length() - 4) + "-dev.jar");
}
return backupTo;
return destination;
}
@TaskAction
public void remap() {
ModRemapper.remap(this);
ModRemapper.remap(this, nestJar);
}
}

View File

@ -42,7 +42,7 @@ import java.util.List;
public class ModRemapper {
public static void remap(RemapJar task) {
public static void remap(RemapJar task, boolean nest) {
Project project = task.getProject();
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");
Path modJarOutputPath = modJarOutput.toPath();
File modJarUnmappedCopy = task.getBackupTo();
File modJarUnmappedCopy = task.getDestination();
if (modJarUnmappedCopy.exists()) {
modJarUnmappedCopy.delete();
}
@ -107,8 +107,10 @@ public class ModRemapper {
project.getLogger().debug("Transformed mixin reference maps in output JAR!");
}
if (NestedJars.addNestedJars(project, modJarOutput)) {
project.getLogger().debug("Added nested jar paths to mod json");
if (nest) {
if (NestedJars.addNestedJars(project, modJarOutput)) {
project.getLogger().debug("Added nested jar paths to mod json");
}
}
try {