Initial untested support for mixin remapping

This commit is contained in:
modmuss50 2016-10-12 15:34:04 +01:00
parent 68cd938036
commit 3ebbd9463c
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
5 changed files with 46 additions and 46 deletions

View file

@ -40,6 +40,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.gradle.plugins.ide.idea.model.IdeaModel;
@ -51,6 +52,8 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
public class AbstractPlugin implements Plugin<Project> {
protected Project project;
@ -87,27 +90,28 @@ public class AbstractPlugin implements Plugin<Project> {
configureIDEs();
configureCompile();
//TODO wait for AP thing
// Map<Project, Set<Task>> taskMap = project.getAllTasks(true);
// for (Map.Entry<Project, Set<Task>> entry : taskMap.entrySet()) {
// Project project = entry.getKey();
// Set<Task> taskSet = entry.getValue();
// for (Task task : taskSet) {
// if (task instanceof JavaCompile) {
// JavaCompile javaCompileTask = (JavaCompile) task;
// javaCompileTask.doFirst(task1 -> {
// project.getLogger().lifecycle(":setting java compiler args");
// try {
// javaCompileTask.getOptions().getCompilerArgs().add("-AreobfNotchSrgFile=" + Constants.MAPPINGS_SRG.get(extension).getCanonicalPath());
// javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=notch");
// } catch (IOException e) {
// e.printStackTrace();
// }
// });
// }
// }
//
// }
Map<Project, Set<Task>> taskMap = project.getAllTasks(true);
for (Map.Entry<Project, Set<Task>> entry : taskMap.entrySet()) {
Project project = entry.getKey();
Set<Task> taskSet = entry.getValue();
for (Task task : taskSet) {
if (task instanceof JavaCompile) {
JavaCompile javaCompileTask = (JavaCompile) task;
javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args");
try {
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFile=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFile=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + Constants.REF_MAP.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=mojang"); //TODO check if this should be pomf?
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
}
}

View file

@ -41,12 +41,11 @@ import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.logging.Logger;
import org.gradle.api.tasks.TaskAction;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
import java.net.URL;
import java.util.Map;
import java.util.Optional;
import java.util.zip.GZIPInputStream;
public class DownloadTask extends DefaultTask {
@TaskAction
@ -78,6 +77,22 @@ public class DownloadTask extends DefaultTask {
FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"), Constants.MAPPINGS_ZIP.get(extension));
}
if (!Constants.MAPPINGS_TINY.get(extension).exists()) {
if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists()) {
getLogger().lifecycle(":downloading tiny mappings");
FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension));
}
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(Constants.MAPPINGS_TINY_GZ.get(extension)));
FileOutputStream fileOutputStream = new FileOutputStream(Constants.MAPPINGS_TINY.get(extension));
int length;
byte[] buffer = new byte[1024];
while ((length = gzipInputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, length);
}
gzipInputStream.close();
fileOutputStream.close();
}
DependencyHandler dependencyHandler = getProject().getDependencies();
if (getProject().getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getState() == Configuration.State.UNRESOLVED) {

View file

@ -49,6 +49,7 @@ public class Constants {
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ""));
public static final IDelayed<File> MAPPINGS_TINY_GZ = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"));
public static final IDelayed<File> MAPPINGS_TINY = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-tiny-" + extension.version + "." + extension.pomfVersion));
public static final IDelayed<File> MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf-tiny-mixin-" + extension.version + "." + extension.pomfVersion));
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "RefMap.json"));

View file

@ -28,18 +28,13 @@ import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.tinyremapper.OutputConsumerJar;
import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.TinyUtils;
import org.apache.commons.io.FileUtils;
import org.gradle.api.Project;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPInputStream;
public class ModRemapper {
@ -53,21 +48,6 @@ public class ModRemapper {
project.getLogger().error("Could not find mod jar @" + modJar.getAbsolutePath());
return;
}
if (!Constants.MAPPINGS_TINY.get(extension).exists()) {
if (!Constants.MAPPINGS_TINY_GZ.get(extension).exists()) {
project.getLogger().lifecycle(":downloading tiny mappings");
FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomfVersion + "/artifact/build/libs/pomf-tiny-" + extension.version + "." + extension.pomfVersion + ".gz"), Constants.MAPPINGS_TINY_GZ.get(extension));
}
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(Constants.MAPPINGS_TINY_GZ.get(extension)));
FileOutputStream fileOutputStream = new FileOutputStream(Constants.MAPPINGS_TINY.get(extension));
int length;
byte[] buffer = new byte[1024];
while ((length = gzipInputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, length);
}
gzipInputStream.close();
fileOutputStream.close();
}
Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath();
@ -78,7 +58,7 @@ public class ModRemapper {
classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT).getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles());
classpathFiles.add(new File(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it
classpathFiles.add(new File(Constants.MINECRAFT_MERGED_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it
Path[] classpath = new Path[classpathFiles.size()];
for (int i = 0; i < classpathFiles.size(); i++) {

View file

@ -24,7 +24,7 @@
package net.fabricmc.loom.util.proccessing;
import net.fabricmc.base.util.MixinPrebaker;
import net.fabricmc.base.util.mixin.MixinPrebaker;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.task.ProcessModsTask;
import net.fabricmc.loom.util.Constants;