diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index dff95f7..2e7dde1 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -84,6 +84,11 @@ public class AbstractPlugin implements Plugin { configureIDEs(); configureCompile(); + if(extension.refmapName == null || extension.refmapName.isEmpty()){ + project.getLogger().warn("Could not find refmap definition, will be using default name: " + project.getName() + "-refmap.json"); + extension.refmapName = project.getName() + "-refmap.json"; + } + Map> taskMap = project.getAllTasks(true); for (Map.Entry> entry : taskMap.entrySet()) { Project project = entry.getKey(); @@ -97,10 +102,6 @@ public class AbstractPlugin implements Plugin { try { javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFileNamedIntermediary=" + extension.getMappingsProvider().MAPPINGS_TINY.getCanonicalPath()); javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFileNamedIntermediary=" + extension.getMappingsProvider().MAPPINGS_MIXIN_EXPORT.getCanonicalPath()); - if(extension.refmapName == null || extension.refmapName.isEmpty()){ - project.getLogger().error("Could not find refmap definition, will be using default name: " + project.getName() + "-refmap.json"); - extension.refmapName = project.getName() + "-refmap.json"; - } javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), extension.refmapName).getCanonicalPath()); javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=named:intermediary"); } catch (IOException e) { @@ -233,6 +234,9 @@ public class AbstractPlugin implements Plugin { remapJarTask.doLast(task -> project1.getArtifacts().add("archives", remapJarTask.jar)); remapJarTask.dependsOn(project1.getTasks().getByName("jar")); project1.getTasks().getByName("build").dependsOn(remapJarTask); + } else { + AbstractArchiveTask jarTask = (AbstractArchiveTask) project1.getTasks().getByName("jar"); + extension.addUnmappedMod(jarTask.getArchivePath()); } }); } diff --git a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java index b890945..4058e58 100644 --- a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java +++ b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java @@ -31,12 +31,17 @@ import net.fabricmc.loom.util.LoomDependencyManager; import org.gradle.api.Project; import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class LoomGradleExtension { public String runDir = "run"; public String refmapName; public boolean remapMod = true; + private List unmappedModsBuilt = new ArrayList<>(); + //Not to be set in the build.gradle private Project project; private LoomDependencyManager dependencyManager; @@ -45,6 +50,14 @@ public class LoomGradleExtension { this.project = project; } + public void addUnmappedMod(File file) { + unmappedModsBuilt.add(file); + } + + public List getUnmappedMods() { + return Collections.unmodifiableList(unmappedModsBuilt); + } + public File getUserCache() { File userCache = new File(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom"); if (!userCache.exists()) { diff --git a/src/main/java/net/fabricmc/loom/task/RunClientTask.java b/src/main/java/net/fabricmc/loom/task/RunClientTask.java index ac69a63..8e8d420 100644 --- a/src/main/java/net/fabricmc/loom/task/RunClientTask.java +++ b/src/main/java/net/fabricmc/loom/task/RunClientTask.java @@ -46,8 +46,7 @@ public class RunClientTask extends JavaExec { for (File file : getProject().getConfigurations().getByName("compile").getFiles()) { libs.add(file.getAbsolutePath()); } - //Used to add the fabric jar that has been built - for (File file : new File(getProject().getBuildDir(), "libs").listFiles()) { + for (File file : extension.getUnmappedMods()) { if (file.isFile()) { libs.add(file.getAbsolutePath()); } diff --git a/src/main/java/net/fabricmc/loom/task/RunServerTask.java b/src/main/java/net/fabricmc/loom/task/RunServerTask.java index dd5e400..38c5607 100644 --- a/src/main/java/net/fabricmc/loom/task/RunServerTask.java +++ b/src/main/java/net/fabricmc/loom/task/RunServerTask.java @@ -42,8 +42,7 @@ public class RunServerTask extends JavaExec { for (File file : getProject().getConfigurations().getByName("compile").getFiles()) { libs.add(file.getAbsolutePath()); } - //Used to add the fabric jar that has been built - for (File file : new File(getProject().getBuildDir(), "libs").listFiles()) { + for (File file : extension.getUnmappedMods()) { if (file.isFile()) { libs.add(file.getAbsolutePath()); } diff --git a/src/main/java/net/fabricmc/loom/util/ModRemapper.java b/src/main/java/net/fabricmc/loom/util/ModRemapper.java index c21e4a6..461b7c5 100644 --- a/src/main/java/net/fabricmc/loom/util/ModRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/ModRemapper.java @@ -66,6 +66,11 @@ public class ModRemapper { File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar"); Path modJarOutputPath = modJarOutput.toPath(); + File modJarUnmappedCopy = new File(s.substring(0, s.length() - 4) + "-dev.jar"); + if (modJarUnmappedCopy.exists()) { + modJarUnmappedCopy.delete(); + } + File mixinMapFile = mappingsProvider.MAPPINGS_MIXIN_EXPORT; Path mixinMapPath = mixinMapFile.toPath(); @@ -99,7 +104,8 @@ public class ModRemapper { } if (modJar.exists()) { - modJar.delete(); + modJar.renameTo(modJarUnmappedCopy); + extension.addUnmappedMod(modJarUnmappedCopy); } modJarOutput.renameTo(modJar);