Fix remapped mods not being resolved by the ide
parent
d908e4129c
commit
356a7c4d00
|
@ -30,6 +30,7 @@ import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.fabricmc.loom.task.DownloadTask;
|
import net.fabricmc.loom.task.DownloadTask;
|
||||||
import net.fabricmc.loom.util.Constants;
|
import net.fabricmc.loom.util.Constants;
|
||||||
|
import net.fabricmc.loom.util.ModProcessor;
|
||||||
import net.fabricmc.loom.util.ModRemapper;
|
import net.fabricmc.loom.util.ModRemapper;
|
||||||
import net.fabricmc.loom.util.Version;
|
import net.fabricmc.loom.util.Version;
|
||||||
import org.gradle.api.Plugin;
|
import org.gradle.api.Plugin;
|
||||||
|
@ -45,7 +46,6 @@ import org.gradle.api.tasks.javadoc.Javadoc;
|
||||||
import org.gradle.plugins.ide.api.GeneratorTask;
|
import org.gradle.plugins.ide.api.GeneratorTask;
|
||||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||||
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
||||||
import org.gradle.plugins.ide.internal.IdePlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -254,6 +254,7 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||||
project1.getDependencies().add(Constants.COMPILE_MODS, "net.fabricmc:fabric-loader:" + extension.getVersionString());
|
project1.getDependencies().add(Constants.COMPILE_MODS, "net.fabricmc:fabric-loader:" + extension.getVersionString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModProcessor.configureModRemapper(project1);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
package net.fabricmc.loom;
|
package net.fabricmc.loom;
|
||||||
|
|
||||||
import net.fabricmc.loom.task.*;
|
import net.fabricmc.loom.task.*;
|
||||||
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
public class LoomGradlePlugin extends AbstractPlugin {
|
public class LoomGradlePlugin extends AbstractPlugin {
|
||||||
|
@ -35,7 +36,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
||||||
makeTask("download", DownloadTask.class);
|
makeTask("download", DownloadTask.class);
|
||||||
makeTask("mergeJars", MergeJarsTask.class).dependsOn("download");
|
makeTask("mergeJars", MergeJarsTask.class).dependsOn("download");
|
||||||
makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars");
|
makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars");
|
||||||
makeTask("setup", SetupTask.class).dependsOn("mapJars").setGroup("fabric");
|
makeTask("setup", DefaultTask.class).dependsOn("mapJars").setGroup("fabric");
|
||||||
|
|
||||||
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
|
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
|
||||||
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.fabricmc.loom.task;
|
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
|
||||||
import net.fabricmc.loom.util.Constants;
|
|
||||||
import net.fabricmc.loom.util.ModProcessor;
|
|
||||||
import org.gradle.api.DefaultTask;
|
|
||||||
import org.gradle.api.artifacts.Configuration;
|
|
||||||
import org.gradle.api.tasks.TaskAction;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class SetupTask extends DefaultTask {
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
public void setup(){
|
|
||||||
configureModRemapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void configureModRemapper(){
|
|
||||||
LoomGradleExtension extension = getProject().getExtensions().getByType(LoomGradleExtension.class);
|
|
||||||
Configuration inputConfig = getProject().getConfigurations().getByName(Constants.COMPILE_MODS);
|
|
||||||
|
|
||||||
inputConfig.getResolvedConfiguration().getFiles().stream()
|
|
||||||
.filter(file -> file.getName().endsWith(".jar"))
|
|
||||||
.forEach(input -> {
|
|
||||||
String outputName = input.getName().substring(0, input.getName().length() - 4) + "-mapped-" + extension.pomfVersion + ".jar";//TODO use the hash of the input file or something?
|
|
||||||
File output = new File(Constants.REMAPPED_MODS_STORE.get(extension), outputName);
|
|
||||||
if(!output.getParentFile().exists()){
|
|
||||||
output.mkdirs();
|
|
||||||
}
|
|
||||||
ModProcessor.handleMod(input, output, getProject());
|
|
||||||
if (!output.exists()) {
|
|
||||||
throw new RuntimeException("Output does not exist!");
|
|
||||||
}
|
|
||||||
getProject().getDependencies().add(Constants.CONFIG_MINECRAFT, getProject().files(output.getPath()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -60,6 +60,26 @@ import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public class ModProcessor {
|
public class ModProcessor {
|
||||||
|
|
||||||
|
public static void configureModRemapper(Project project){
|
||||||
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
Configuration inputConfig = project.getConfigurations().getByName(Constants.COMPILE_MODS);
|
||||||
|
|
||||||
|
inputConfig.getResolvedConfiguration().getFiles().stream()
|
||||||
|
.filter(file -> file.getName().endsWith(".jar"))
|
||||||
|
.forEach(input -> {
|
||||||
|
String outputName = input.getName().substring(0, input.getName().length() - 4) + "-mapped-" + extension.pomfVersion + ".jar";//TODO use the hash of the input file or something?
|
||||||
|
File output = new File(Constants.REMAPPED_MODS_STORE.get(extension), outputName);
|
||||||
|
if(!output.getParentFile().exists()){
|
||||||
|
output.mkdirs();
|
||||||
|
}
|
||||||
|
ModProcessor.handleMod(input, output, project);
|
||||||
|
if (!output.exists()) {
|
||||||
|
throw new RuntimeException("Output does not exist!");
|
||||||
|
}
|
||||||
|
project.getDependencies().add(Constants.CONFIG_MINECRAFT, project.files(output.getPath()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void handleMod(File input, File output, Project project){
|
public static void handleMod(File input, File output, Project project){
|
||||||
if(output.exists()){
|
if(output.exists()){
|
||||||
output.delete();
|
output.delete();
|
||||||
|
|
Loading…
Reference in New Issue