clean mapping provider code
This commit is contained in:
parent
807fb38736
commit
da675e9545
12 changed files with 46 additions and 65 deletions
|
@ -25,10 +25,9 @@
|
|||
package net.fabricmc.loom;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.ModRemapperProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.task.RemapJar;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.LoomDependencyManager;
|
||||
|
@ -44,7 +43,6 @@ import org.gradle.api.tasks.SourceSet;
|
|||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.api.tasks.javadoc.Javadoc;
|
||||
import org.gradle.jvm.tasks.Jar;
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
||||
|
||||
|
@ -97,8 +95,8 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
javaCompileTask.doFirst(task1 -> {
|
||||
project.getLogger().lifecycle(":setting java compiler args");
|
||||
try {
|
||||
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFileNamedIntermediary=" + extension.getPomfProvider().MAPPINGS_TINY.getCanonicalPath());
|
||||
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFileNamedIntermediary=" + extension.getPomfProvider().MAPPINGS_MIXIN_EXPORT.getCanonicalPath());
|
||||
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";
|
||||
|
@ -217,7 +215,7 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
extension.setDependencyManager(dependencyManager);
|
||||
|
||||
dependencyManager.addProvider(new MinecraftProvider());
|
||||
dependencyManager.addProvider(new PomfProvider());
|
||||
dependencyManager.addProvider(new MappingsProvider());
|
||||
dependencyManager.addProvider(new ModRemapperProvider());
|
||||
|
||||
dependencyManager.handleDependencies(project1);
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
package net.fabricmc.loom;
|
||||
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.util.LoomDependencyManager;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
|
@ -62,11 +62,11 @@ public class LoomGradleExtension {
|
|||
}
|
||||
|
||||
public MinecraftMappedProvider getMinecraftMappedProvider(){
|
||||
return getPomfProvider().mappedProvider;
|
||||
return getMappingsProvider().mappedProvider;
|
||||
}
|
||||
|
||||
public PomfProvider getPomfProvider(){
|
||||
return getDependencyManager().getProvider(PomfProvider.class);
|
||||
public MappingsProvider getMappingsProvider(){
|
||||
return getDependencyManager().getProvider(MappingsProvider.class);
|
||||
}
|
||||
|
||||
public void setDependencyManager(LoomDependencyManager dependencyManager) {
|
||||
|
|
|
@ -38,13 +38,14 @@ import java.nio.file.Path;
|
|||
|
||||
//TODO fix local mappings
|
||||
//TODO possibly use maven for mappings, can fix above at the same time
|
||||
public class PomfProvider extends DependencyProvider {
|
||||
public class MappingsProvider extends DependencyProvider {
|
||||
public MinecraftMappedProvider mappedProvider;
|
||||
|
||||
public String mappingsName;
|
||||
public String minecraftVersion;
|
||||
public String pomfVersion;
|
||||
public String mappingsVersion;
|
||||
|
||||
private File POMF_DIR;
|
||||
private File MAPPINGS_DIR;
|
||||
public File MAPPINGS_TINY_BASE;
|
||||
public File MAPPINGS_TINY;
|
||||
|
||||
|
@ -54,20 +55,21 @@ public class PomfProvider extends DependencyProvider {
|
|||
public void provide(DependencyInfo dependency, Project project, LoomGradleExtension extension) throws Exception {
|
||||
MinecraftProvider minecraftProvider = getDependencyManager().getProvider(MinecraftProvider.class);
|
||||
|
||||
project.getLogger().lifecycle(":setting up pomf " + dependency.getDependency().getVersion());
|
||||
project.getLogger().lifecycle(":setting up mappings (" + dependency.getDependency().getName() + " " + dependency.getDependency().getVersion() + ")");
|
||||
|
||||
String version = dependency.getDependency().getVersion();
|
||||
String[] split = version.split("\\.");
|
||||
|
||||
File mappingsJar = dependency.resolveFile();
|
||||
|
||||
this.mappingsName = dependency.getDependency().getName();
|
||||
this.minecraftVersion = split[0];
|
||||
this.pomfVersion = split[1];
|
||||
this.mappingsVersion = split[1];
|
||||
|
||||
initFiles(project);
|
||||
|
||||
if (!POMF_DIR.exists()) {
|
||||
POMF_DIR.mkdir();
|
||||
if (!MAPPINGS_DIR.exists()) {
|
||||
MAPPINGS_DIR.mkdir();
|
||||
}
|
||||
|
||||
if (!MAPPINGS_TINY_BASE.exists() || !MAPPINGS_TINY.exists()) {
|
||||
|
@ -91,7 +93,7 @@ public class PomfProvider extends DependencyProvider {
|
|||
});
|
||||
}
|
||||
|
||||
project.getDependencies().add("compile", project.getDependencies().module("net.fabricmc:pomf:" + version));
|
||||
project.getDependencies().add("compile", project.getDependencies().module(dependency.getDependency().getGroup() + ":" + dependency.getDependency().getName() + ":" + version));
|
||||
|
||||
mappedProvider = new MinecraftMappedProvider();
|
||||
mappedProvider.initFiles(project, minecraftProvider, this);
|
||||
|
@ -100,11 +102,11 @@ public class PomfProvider extends DependencyProvider {
|
|||
|
||||
public void initFiles(Project project) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
POMF_DIR = new File(extension.getUserCache(), "pomf");
|
||||
MAPPINGS_DIR = new File(extension.getUserCache(), "mappings");
|
||||
|
||||
MAPPINGS_TINY_BASE = new File(POMF_DIR, "pomf-tiny-" + minecraftVersion + "." + pomfVersion + "-base");
|
||||
MAPPINGS_TINY = new File(POMF_DIR, "pomf-tiny-" + minecraftVersion + "." + pomfVersion);
|
||||
MAPPINGS_MIXIN_EXPORT = new File(Constants.CACHE_FILES, "mixin-map-" + minecraftVersion + "." + pomfVersion + ".tiny");
|
||||
MAPPINGS_TINY_BASE = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "." + mappingsVersion + "-base");
|
||||
MAPPINGS_TINY = new File(MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "." + mappingsVersion);
|
||||
MAPPINGS_MIXIN_EXPORT = new File(Constants.CACHE_FILES, "mixin-map-" + minecraftVersion + "." + mappingsVersion + ".tiny");
|
||||
}
|
||||
|
||||
@Override
|
|
@ -25,13 +25,10 @@
|
|||
package net.fabricmc.loom.providers;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.task.GenSourcesTask;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyProvider;
|
||||
import net.fabricmc.loom.util.MapJarsTiny;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
@ -58,15 +55,15 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
|||
throw new RuntimeException("mapped jar not found");
|
||||
}
|
||||
|
||||
String version = minecraftProvider.minecraftVersion + "-mapped-" + extension.getPomfProvider().pomfVersion;
|
||||
String version = minecraftProvider.minecraftVersion + "-mapped-" + extension.getMappingsProvider().mappingsVersion;
|
||||
project.getDependencies().add("compile", project.getDependencies().module("net.minecraft:minecraft:" + version));
|
||||
}
|
||||
|
||||
public void initFiles(Project project, MinecraftProvider minecraftProvider, PomfProvider pomfProvider) {
|
||||
public void initFiles(Project project, MinecraftProvider minecraftProvider, MappingsProvider mappingsProvider) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
this.minecraftProvider = minecraftProvider;
|
||||
MINECRAFT_INTERMEDIARY_JAR = new File(extension.getUserCache(), "minecraft-" + minecraftProvider.minecraftVersion + "-intermediary.jar");
|
||||
MINECRAFT_MAPPED_JAR = new File(extension.getUserCache(), "minecraft-" + minecraftProvider.minecraftVersion + "-mapped-" + pomfProvider.pomfVersion + ".jar");
|
||||
MINECRAFT_MAPPED_JAR = new File(extension.getUserCache(), "minecraft-" + minecraftProvider.minecraftVersion + "-mapped-" + mappingsProvider.mappingsVersion + ".jar");
|
||||
}
|
||||
|
||||
public Collection<File> getMapperPaths() {
|
||||
|
|
|
@ -39,9 +39,9 @@ public class ModRemapperProvider extends DependencyProvider {
|
|||
|
||||
project.getLogger().lifecycle("Providing " + dependency.getDepString());
|
||||
|
||||
PomfProvider pomfProvider = getDependencyManager().getProvider(PomfProvider.class);
|
||||
MappingsProvider mappingsProvider = getDependencyManager().getProvider(MappingsProvider.class);
|
||||
|
||||
String outputName = input.getName().substring(0, input.getName().length() - 4) + "-mapped-" + pomfProvider.pomfVersion + ".jar";//TODO use the hash of the input file or something?
|
||||
String outputName = input.getName().substring(0, input.getName().length() - 4) + "-mapped-" + mappingsProvider.mappingsVersion + ".jar";//TODO use the hash of the input file or something?
|
||||
File output = new File(Constants.REMAPPED_MODS_STORE, outputName);
|
||||
if(output.exists()){
|
||||
output.delete();
|
||||
|
|
|
@ -32,8 +32,8 @@ public class GenSourcesCfrTask extends DefaultTask {
|
|||
public void genSources() throws IOException {
|
||||
Project project = this.getProject();
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
File mappedJar = pomfProvider.mappedProvider.getMappedJar();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||
File sourcesJar = getSourcesJar(project);
|
||||
|
||||
Manifest manifest = new Manifest();
|
||||
|
|
|
@ -26,13 +26,11 @@ package net.fabricmc.loom.task;
|
|||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftLibraryProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.jetbrains.java.decompiler.main.ClassReference14Processor;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
@ -48,8 +46,8 @@ import java.util.jar.*;
|
|||
public class GenSourcesTask extends DefaultTask {
|
||||
public static File getSourcesJar(Project project) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
File mappedJar = pomfProvider.mappedProvider.getMappedJar();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||
String path = mappedJar.getAbsolutePath();
|
||||
if (!path.toLowerCase(Locale.ROOT).endsWith(".jar")) {
|
||||
throw new RuntimeException("Invalid mapped JAR path: " + path);
|
||||
|
@ -63,8 +61,8 @@ public class GenSourcesTask extends DefaultTask {
|
|||
Project project = this.getProject();
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
MinecraftLibraryProvider libraryProvider = extension.getMinecraftProvider().libraryProvider;
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
File mappedJar = pomfProvider.mappedProvider.getMappedJar();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||
File sourcesJar = getSourcesJar(project);
|
||||
|
||||
Manifest manifest = new Manifest();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
package net.fabricmc.loom.task;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MinecraftVersionInfo;
|
||||
import org.gradle.api.tasks.JavaExec;
|
||||
|
@ -40,7 +40,7 @@ public class RunClientTask extends JavaExec {
|
|||
public void exec() {
|
||||
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
|
||||
MinecraftVersionInfo minecraftVersionInfo = extension.getMinecraftProvider().versionInfo;
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
|
||||
List<String> libs = new ArrayList<>();
|
||||
for (File file : getProject().getConfigurations().getByName("compile").getFiles()) {
|
||||
|
|
|
@ -32,10 +32,8 @@ public class Constants {
|
|||
|
||||
public static final File REMAPPED_MODS_STORE = new File(CACHE_FILES, "remapped_mods");
|
||||
|
||||
|
||||
public static final String FABRIC_CLIENT_TWEAKER = "net.fabricmc.loader.launch.FabricClientTweaker";
|
||||
public static final String FABRIC_SERVER_TWEAKER = "net.fabricmc.loader.launch.FabricServerTweaker";
|
||||
public static final String POMF_MAVEN_SERVER = "https://maven.fabricmc.net/net/fabricmc/pomf/";
|
||||
|
||||
public static final String LIBRARIES_BASE = "https://libraries.minecraft.net/";
|
||||
public static final String RESOURCES_BASE = "http://resources.download.minecraft.net/";
|
||||
|
|
|
@ -28,7 +28,7 @@ package net.fabricmc.loom.util;
|
|||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MinecraftJarProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
import net.fabricmc.tinyremapper.TinyUtils;
|
||||
|
@ -45,9 +45,9 @@ public class MapJarsTiny {
|
|||
String fromM = "official";
|
||||
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
|
||||
Path mappings = pomfProvider.MAPPINGS_TINY.toPath();
|
||||
Path mappings = mappingsProvider.MAPPINGS_TINY.toPath();
|
||||
Path[] classpath = mapProvider.getMapperPaths().stream()
|
||||
.map(File::toPath)
|
||||
.toArray(Path[]::new);
|
||||
|
|
|
@ -25,13 +25,11 @@
|
|||
package net.fabricmc.loom.util;
|
||||
|
||||
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.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.providers.MinecraftProvider;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
import net.fabricmc.tinyremapper.TinyUtils;
|
||||
|
@ -40,24 +38,14 @@ import org.gradle.api.Project;
|
|||
import org.gradle.api.artifacts.Configuration;
|
||||
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.zeroturnaround.zip.ZipUtil;
|
||||
import org.zeroturnaround.zip.transform.StringZipEntryTransformer;
|
||||
import org.zeroturnaround.zip.transform.ZipEntryTransformerEntry;
|
||||
|
||||
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.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
|
@ -82,9 +70,9 @@ public class ModProcessor {
|
|||
|
||||
MinecraftProvider minecraftProvider = extension.getMinecraftProvider();
|
||||
MinecraftMappedProvider mappedProvider = extension.getMinecraftMappedProvider();
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
|
||||
File mappingsFile = pomfProvider.MAPPINGS_TINY;
|
||||
File mappingsFile = mappingsProvider.MAPPINGS_TINY;
|
||||
Path mappings = mappingsFile.toPath();
|
||||
Path mc = mappedProvider.MINECRAFT_INTERMEDIARY_JAR.toPath();
|
||||
Path[] mcDeps = mappedProvider.getMapperPaths().stream()
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
package net.fabricmc.loom.util;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.PomfProvider;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import net.fabricmc.loom.task.RemapJar;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
|
@ -50,9 +50,9 @@ public class ModRemapper {
|
|||
return;
|
||||
}
|
||||
|
||||
PomfProvider pomfProvider = extension.getPomfProvider();
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
|
||||
Path mappings = pomfProvider.MAPPINGS_TINY.toPath();
|
||||
Path mappings = mappingsProvider.MAPPINGS_TINY.toPath();
|
||||
|
||||
String fromM = "named";
|
||||
String toM = "intermediary";
|
||||
|
@ -66,7 +66,7 @@ public class ModRemapper {
|
|||
File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar");
|
||||
Path modJarOutputPath = modJarOutput.toPath();
|
||||
|
||||
File mixinMapFile = pomfProvider.MAPPINGS_MIXIN_EXPORT;
|
||||
File mixinMapFile = mappingsProvider.MAPPINGS_MIXIN_EXPORT;
|
||||
Path mixinMapPath = mixinMapFile.toPath();
|
||||
|
||||
TinyRemapper.Builder remapperBuilder = TinyRemapper.newRemapper();
|
||||
|
|
Loading…
Reference in a new issue