From 14fb3373305b61ed7e6849c4e6a6922d9cbebdc4 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sun, 16 Oct 2016 11:49:16 +0200 Subject: [PATCH] work on refmap inclusion, mixin applying --- .../java/net/fabricmc/loom/AbstractPlugin.java | 6 ++++-- .../java/net/fabricmc/loom/util/Constants.java | 4 ++-- .../java/net/fabricmc/loom/util/ModRemapper.java | 15 +++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index 4e98604..cddf32b 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -96,15 +96,17 @@ public class AbstractPlugin implements Plugin { Project project = entry.getKey(); Set taskSet = entry.getValue(); for (Task task : taskSet) { - if (task instanceof JavaCompile) { + if (task instanceof JavaCompile + && !(task.getName().contains("Test")) && !(task.getName().contains("test"))) { JavaCompile javaCompileTask = (JavaCompile) task; javaCompileTask.doFirst(task1 -> { project.getLogger().lifecycle(":setting java compiler args"); try { javaCompileTask.getClasspath().add(target.files(this.getClass().getProtectionDomain().getCodeSource().getLocation())); + javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFilePomfMojang=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath()); javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFilePomfMojang=" + Constants.MAPPINGS_MIXIN_EXPORT.get(extension).getCanonicalPath()); - javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + Constants.REF_MAP.get(extension).getCanonicalPath()); + javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), ".mixin-refmap.json").getCanonicalPath()); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java index cb69adb..0fa5b13 100644 --- a/src/main/java/net/fabricmc/loom/util/Constants.java +++ b/src/main/java/net/fabricmc/loom/util/Constants.java @@ -49,9 +49,9 @@ public class Constants { public static final IDelayed MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + "")); public static final IDelayed MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz")); public static final IDelayed MAPPINGS_TINY = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion)); - public static final IDelayed MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf-tiny-mixin-" + extension.version + "." + extension.pomfVersion)); + public static final IDelayed MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-map-" + extension.version + "." + extension.pomfVersion)); - public static final IDelayed REF_MAP = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "RefMap.json")); + public static final IDelayed REF_MAP = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-refmap.json")); public static final IDelayed MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs")); public static final IDelayed MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-natives")); diff --git a/src/main/java/net/fabricmc/loom/util/ModRemapper.java b/src/main/java/net/fabricmc/loom/util/ModRemapper.java index d81a290..ed33f48 100644 --- a/src/main/java/net/fabricmc/loom/util/ModRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/ModRemapper.java @@ -32,6 +32,7 @@ import org.gradle.api.Project; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -42,12 +43,17 @@ public class ModRemapper { LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); //TODO whats the proper way of doing this??? File libsDir = new File(project.getBuildDir(), "libs"); - File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar"); - File modOutputJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-final.jar"); - if (!modJar.exists()) { + File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-unmapped.jar"); + File modMappedJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar"); + if (!modMappedJar.exists()) { project.getLogger().error("Could not find mod jar @" + modJar.getAbsolutePath()); return; } + if (modJar.exists()) { + modJar.delete(); + } + + modMappedJar.renameTo(modJar); Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath(); @@ -67,9 +73,10 @@ public class ModRemapper { TinyRemapper remapper = TinyRemapper.newRemapper() .withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM)) + .withMappings(TinyUtils.createTinyMappingProvider(Constants.MAPPINGS_MIXIN_EXPORT.get(extension).toPath(), fromM, toM)) .build(); - OutputConsumerPath outputConsumer = new OutputConsumerPath(modOutputJar.toPath()); + OutputConsumerPath outputConsumer = new OutputConsumerPath(modMappedJar.toPath()); outputConsumer.addNonClassFiles(modJar.toPath()); remapper.read(modJar.toPath()); remapper.read(classpath);