From e274d0c8c5721ed2abbfb87e18d18282d15bce9d Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 23 Oct 2016 17:31:56 +0100 Subject: [PATCH] Improve mod re-mapper --- .../net/fabricmc/loom/AbstractPlugin.java | 2 +- .../fabricmc/loom/task/ProcessModsTask.java | 2 -- .../net/fabricmc/loom/util/ModRemapper.java | 28 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index 281c24b..9b3b26f 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -241,7 +241,7 @@ public class AbstractPlugin implements Plugin { if (extension.fabricVersion != null && !extension.fabricVersion.isEmpty()) { //only add this when not in a fabric dev env - project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.fabricmc:fabric-base:" + extension.version + "-" + extension.fabricVersion); + project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.fabricmc:fabric-base:" + extension.version + "-" + extension.fabricVersion + ":debof"); } project1.getDependencies().add(Constants.PROCESS_MODS_DEPENDENCIES, "net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT"); }); diff --git a/src/main/java/net/fabricmc/loom/task/ProcessModsTask.java b/src/main/java/net/fabricmc/loom/task/ProcessModsTask.java index e5cb902..8496c05 100644 --- a/src/main/java/net/fabricmc/loom/task/ProcessModsTask.java +++ b/src/main/java/net/fabricmc/loom/task/ProcessModsTask.java @@ -59,8 +59,6 @@ public class ProcessModsTask extends DefaultTask { if (mods.size() == 0) { FileUtils.copyFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), Constants.MINECRAFT_FINAL_JAR.get(extension)); } else { - //TODO figure out a way to specify what deps do what - //TODO download deps when needed downloadRequiredDeps(extension); new PreBakeMixins().proccess(getProject(), extension, mods); } diff --git a/src/main/java/net/fabricmc/loom/util/ModRemapper.java b/src/main/java/net/fabricmc/loom/util/ModRemapper.java index f8a6cc9..17e8281 100644 --- a/src/main/java/net/fabricmc/loom/util/ModRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/ModRemapper.java @@ -42,17 +42,19 @@ 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() + "-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()); + File debofJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-debof.jar"); + File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar"); + if (!modJar.exists()) { + project.getLogger().error("Could not find mod jar @" + debofJar.getAbsolutePath()); + project.getLogger().error("This is can be fixed by adding a 'settings.gradle' file specifying 'rootProject.name'"); return; } - if (modJar.exists()) { - modJar.delete(); + if (debofJar.exists()) { + debofJar.delete(); } - modMappedJar.renameTo(modJar); + //Move the pre existing mod jar to the debof jar + modJar.renameTo(debofJar); Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath(); @@ -75,12 +77,16 @@ public class ModRemapper { .withMappings(TinyUtils.createTinyMappingProvider(Constants.MAPPINGS_MIXIN_EXPORT.get(extension).toPath(), fromM, toM)) .build(); - OutputConsumerPath outputConsumer = new OutputConsumerPath(modMappedJar.toPath()); - outputConsumer.addNonClassFiles(modJar.toPath()); - remapper.read(modJar.toPath()); + OutputConsumerPath outputConsumer = new OutputConsumerPath(modJar.toPath()); + //Rebof the debof jar + outputConsumer.addNonClassFiles(debofJar.toPath()); + remapper.read(debofJar.toPath()); remapper.read(classpath); - remapper.apply(modJar.toPath(), outputConsumer); + remapper.apply(debofJar.toPath(), outputConsumer); outputConsumer.finish(); remapper.finish(); + + //Add the debof jar to be uploaded to maven + project.getArtifacts().add("archives", debofJar); } }