Revert "Fix remapped mods not being resolved by the ide"

This reverts commit 356a7c4
dev/0.11
modmuss50 2018-11-03 17:24:16 +00:00
parent 0c6d36b3b7
commit 0770c57d6d
4 changed files with 71 additions and 32 deletions

View File

@ -30,7 +30,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.loom.task.DownloadTask;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.ModProcessor;
import net.fabricmc.loom.util.ModRemapper;
import net.fabricmc.loom.util.Version;
import org.gradle.api.Plugin;
@ -254,7 +253,6 @@ public class AbstractPlugin implements Plugin<Project> {
project1.getDependencies().add(Constants.COMPILE_MODS, "net.fabricmc:fabric-loader:" + extension.getVersionString());
}
ModProcessor.configureModRemapper(project1);
});

View File

@ -25,7 +25,6 @@
package net.fabricmc.loom;
import net.fabricmc.loom.task.*;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
public class LoomGradlePlugin extends AbstractPlugin {
@ -36,7 +35,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
makeTask("download", DownloadTask.class);
makeTask("mergeJars", MergeJarsTask.class).dependsOn("download");
makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars");
makeTask("setup", DefaultTask.class).dependsOn("mapJars").setGroup("fabric");
makeTask("setup", SetupTask.class).dependsOn("mapJars").setGroup("fabric");
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
makeTask("genIdeaWorkspace", GenIdeaProjectTask.class).dependsOn("idea").setGroup("ide");

View File

@ -0,0 +1,62 @@
/*
* 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()));
});
}
}

View File

@ -24,14 +24,11 @@
package net.fabricmc.loom.util;
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.mixin.MixinMappingProviderTiny;
import net.fabricmc.tinyremapper.OutputConsumerPath;
import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.TinyUtils;
@ -42,44 +39,27 @@ import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.objectweb.asm.commons.Remapper;
import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
import org.spongepowered.asm.obfuscation.mapping.common.MappingField;
import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.transform.StringZipEntryTransformer;
import org.zeroturnaround.zip.transform.ZipEntryTransformerEntry;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
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){
if(output.exists()){
output.delete();