updateMappings -> migrateMappings, new features

dev/0.11
asie 2019-05-10 13:55:17 +02:00
parent 64c21c01b8
commit 1c56fb2eda
3 changed files with 44 additions and 10 deletions

View File

@ -25,13 +25,9 @@
package net.fabricmc.loom;
import net.fabricmc.loom.providers.MappingsProvider;
import net.fabricmc.loom.providers.MinecraftAssetsProvider;
import net.fabricmc.loom.providers.MinecraftLibraryProvider;
import net.fabricmc.loom.task.*;
import net.fabricmc.loom.task.fernflower.FernFlowerTask;
import net.fabricmc.loom.util.LineNumberRemapper;
import net.fabricmc.loom.util.progress.ProgressLogger;
import net.fabricmc.stitch.util.StitchUtil;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.TaskContainer;
@ -64,7 +60,7 @@ public class LoomGradlePlugin extends AbstractPlugin {
tasks.register("cleanLoomBinaries", CleanLoomBinaries.class);
tasks.register("cleanLoomMappings", CleanLoomMappings.class);
tasks.register("updateMappings", UpdateMappingsTask.class, t -> {
tasks.register("migrateMappings", MigrateMappingsTask.class, t -> {
t.getOutputs().upToDateWhen((o) -> false);
});

View File

@ -51,7 +51,7 @@ public class MappingsProvider extends DependencyProvider {
public String minecraftVersion;
public String mappingsVersion;
private File MAPPINGS_DIR;
public File MAPPINGS_DIR;
public File MAPPINGS_TINY_BASE;
public File MAPPINGS_TINY;
public File MAPPINGS_MIXIN_EXPORT;

View File

@ -26,6 +26,7 @@ package net.fabricmc.loom.task;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.Version;
import net.fabricmc.mappings.*;
import org.cadixdev.lorenz.MappingSet;
import org.cadixdev.lorenz.io.MappingsReader;
@ -40,17 +41,54 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class UpdateMappingsTask extends AbstractLoomTask {
public class MigrateMappingsTask extends AbstractLoomTask {
@TaskAction
public void doTask() throws Throwable {
Project project = getProject();
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
Map<String, ?> properties = project.getProperties();
project.getLogger().lifecycle(":loading mappings");
File mappingsFile = new File((String) project.getProperties().get("targetMappingsFile"));
File inputDir = new File((String) project.getProperties().get("inputDir"));
File outputDir = new File((String) project.getProperties().get("outputDir"));
File mappingsFile = null;
if (properties.containsKey("targetMappingsFile")) {
mappingsFile = new File((String) properties.get("targetMappingsFile"));
} else if (properties.containsKey("targetMappingsArtifact")) {
String[] artifactName = ((String) properties.get("targetMappingsArtifact")).split(":");
if (artifactName.length != 3) {
throw new RuntimeException("Invalid artifact name: " + properties.get("targetMappingsArtifact"));
}
String mappingsName = artifactName[0] + "." + artifactName[1];
Version v = new Version(artifactName[2]);
String minecraftVersion = v.getMinecraftVersion();
String mappingsVersion = v.getMappingsVersion();
mappingsFile = new File(extension.getMappingsProvider().MAPPINGS_DIR, mappingsName + "-tiny-" + minecraftVersion + "-" + mappingsVersion);
}
if (mappingsFile == null || !mappingsFile.exists()) {
throw new RuntimeException("Could not find mappings file: " + (mappingsFile != null ? mappingsFile : "null"));
}
if (!properties.containsKey("inputDir") || !properties.containsKey("outputDir")) {
throw new RuntimeException("Must specify input and output dir!");
}
File inputDir = new File((String) properties.get("inputDir"));
File outputDir = new File((String) properties.get("outputDir"));
if (!inputDir.exists() || !inputDir.isDirectory()) {
throw new RuntimeException("Could not find input directory: " + inputDir);
}
if (!outputDir.exists()) {
if (!outputDir.mkdirs()) {
throw new RuntimeException("Could not create output directory:" + outputDir);
}
}
Mappings sourceMappings = extension.getMappingsProvider().getMappings();
Mappings targetMappings;