From 3ebbd9463cdffacf82e7c63b2649d0354ecdfc48 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 12 Oct 2016 15:34:04 +0100 Subject: [PATCH] Initial untested support for mixin remapping --- .../net/fabricmc/loom/AbstractPlugin.java | 46 ++++++++++--------- .../net/fabricmc/loom/task/DownloadTask.java | 21 +++++++-- .../net/fabricmc/loom/util/Constants.java | 1 + .../net/fabricmc/loom/util/ModRemapper.java | 22 +-------- .../loom/util/proccessing/PreBakeMixins.java | 2 +- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index 410a60f..4d2c1a8 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -40,6 +40,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.plugins.ide.eclipse.model.EclipseModel; import org.gradle.plugins.ide.idea.model.IdeaModel; @@ -51,6 +52,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.util.Map; +import java.util.Set; public class AbstractPlugin implements Plugin { protected Project project; @@ -87,27 +90,28 @@ public class AbstractPlugin implements Plugin { configureIDEs(); configureCompile(); - //TODO wait for AP thing -// Map> taskMap = project.getAllTasks(true); -// for (Map.Entry> entry : taskMap.entrySet()) { -// Project project = entry.getKey(); -// Set taskSet = entry.getValue(); -// for (Task task : taskSet) { -// if (task instanceof JavaCompile) { -// JavaCompile javaCompileTask = (JavaCompile) task; -// javaCompileTask.doFirst(task1 -> { -// project.getLogger().lifecycle(":setting java compiler args"); -// try { -// javaCompileTask.getOptions().getCompilerArgs().add("-AreobfNotchSrgFile=" + Constants.MAPPINGS_SRG.get(extension).getCanonicalPath()); -// javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=notch"); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// } -// } -// -// } + Map> taskMap = project.getAllTasks(true); + for (Map.Entry> entry : taskMap.entrySet()) { + Project project = entry.getKey(); + Set taskSet = entry.getValue(); + for (Task task : taskSet) { + if (task instanceof JavaCompile) { + JavaCompile javaCompileTask = (JavaCompile) task; + javaCompileTask.doFirst(task1 -> { + project.getLogger().lifecycle(":setting java compiler args"); + try { + javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFile=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath()); + javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFile=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath()); + javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + Constants.REF_MAP.get(extension).getCanonicalPath()); + javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=mojang"); //TODO check if this should be pomf? + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + } + + } } diff --git a/src/main/java/net/fabricmc/loom/task/DownloadTask.java b/src/main/java/net/fabricmc/loom/task/DownloadTask.java index 2a54623..795e6dc 100644 --- a/src/main/java/net/fabricmc/loom/task/DownloadTask.java +++ b/src/main/java/net/fabricmc/loom/task/DownloadTask.java @@ -41,12 +41,11 @@ import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.logging.Logger; import org.gradle.api.tasks.TaskAction; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; +import java.io.*; import java.net.URL; import java.util.Map; import java.util.Optional; +import java.util.zip.GZIPInputStream; public class DownloadTask extends DefaultTask { @TaskAction @@ -78,6 +77,22 @@ public class DownloadTask extends DefaultTask { FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension)); } + if (!Constants.MAPPINGS_TINY.get(extension).exists()) { + if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists()) { + getLogger().lifecycle(":downloading tiny mappings"); + FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension)); + } + GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(Constants.MAPPINGS_TINY_GZ.get(extension))); + FileOutputStream fileOutputStream = new FileOutputStream(Constants.MAPPINGS_TINY.get(extension)); + int length; + byte[] buffer = new byte[1024]; + while ((length = gzipInputStream.read(buffer)) > 0) { + fileOutputStream.write(buffer, 0, length); + } + gzipInputStream.close(); + fileOutputStream.close(); + } + DependencyHandler dependencyHandler = getProject().getDependencies(); if (getProject().getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getState() == Configuration.State.UNRESOLVED) { diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java index d51d18f..cb69adb 100644 --- a/src/main/java/net/fabricmc/loom/util/Constants.java +++ b/src/main/java/net/fabricmc/loom/util/Constants.java @@ -49,6 +49,7 @@ 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 REF_MAP = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "RefMap.json")); diff --git a/src/main/java/net/fabricmc/loom/util/ModRemapper.java b/src/main/java/net/fabricmc/loom/util/ModRemapper.java index bcbacec..a49c99a 100644 --- a/src/main/java/net/fabricmc/loom/util/ModRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/ModRemapper.java @@ -28,18 +28,13 @@ import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.tinyremapper.OutputConsumerJar; import net.fabricmc.tinyremapper.TinyRemapper; import net.fabricmc.tinyremapper.TinyUtils; -import org.apache.commons.io.FileUtils; import org.gradle.api.Project; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.net.URL; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.zip.GZIPInputStream; public class ModRemapper { @@ -53,21 +48,6 @@ public class ModRemapper { project.getLogger().error("Could not find mod jar @" + modJar.getAbsolutePath()); return; } - if (!Constants.MAPPINGS_TINY.get(extension).exists()) { - if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists()) { - project.getLogger().lifecycle(":downloading tiny mappings"); - FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension)); - } - GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(Constants.MAPPINGS_TINY_GZ.get(extension))); - FileOutputStream fileOutputStream = new FileOutputStream(Constants.MAPPINGS_TINY.get(extension)); - int length; - byte[] buffer = new byte[1024]; - while ((length = gzipInputStream.read(buffer)) > 0) { - fileOutputStream.write(buffer, 0, length); - } - gzipInputStream.close(); - fileOutputStream.close(); - } Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath(); @@ -78,7 +58,7 @@ public class ModRemapper { classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT).getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles()); - classpathFiles.add(new File(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it + classpathFiles.add(new File(Constants.MINECRAFT_MERGED_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it Path[] classpath = new Path[classpathFiles.size()]; for (int i = 0; i < classpathFiles.size(); i++) { diff --git a/src/main/java/net/fabricmc/loom/util/proccessing/PreBakeMixins.java b/src/main/java/net/fabricmc/loom/util/proccessing/PreBakeMixins.java index f934062..2095952 100644 --- a/src/main/java/net/fabricmc/loom/util/proccessing/PreBakeMixins.java +++ b/src/main/java/net/fabricmc/loom/util/proccessing/PreBakeMixins.java @@ -24,7 +24,7 @@ package net.fabricmc.loom.util.proccessing; -import net.fabricmc.base.util.MixinPrebaker; +import net.fabricmc.base.util.mixin.MixinPrebaker; import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.task.ProcessModsTask; import net.fabricmc.loom.util.Constants;