work on refmap inclusion, mixin applying

dev/0.11
asiekierka 2016-10-16 11:49:16 +02:00
parent f2933cb818
commit 14fb337330
3 changed files with 17 additions and 8 deletions

View File

@ -96,15 +96,17 @@ public class AbstractPlugin implements Plugin<Project> {
Project project = entry.getKey();
Set<Task> taskSet = entry.getValue();
for (Task task : taskSet) {
if (task instanceof JavaCompile) {
if (task instanceof JavaCompile
&& !(task.getName().contains("Test")) && !(task.getName().contains("test"))) {
JavaCompile javaCompileTask = (JavaCompile) task;
javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args");
try {
javaCompileTask.getClasspath().add(target.files(this.getClass().getProtectionDomain().getCodeSource().getLocation()));
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFilePomfMojang=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFilePomfMojang=" + Constants.MAPPINGS_MIXIN_EXPORT.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + Constants.REF_MAP.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), ".mixin-refmap.json").getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -49,9 +49,9 @@ 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> MAPPINGS_MIXIN_EXPORT = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-map-" + extension.version + "." + extension.pomfVersion));
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "RefMap.json"));
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-refmap.json"));
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs"));
public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-natives"));

View File

@ -32,6 +32,7 @@ import org.gradle.api.Project;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@ -42,12 +43,17 @@ public class ModRemapper {
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
//TODO whats the proper way of doing this???
File libsDir = new File(project.getBuildDir(), "libs");
File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar");
File modOutputJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-final.jar");
if (!modJar.exists()) {
File modJar = new File(libsDir, project.getName() + "-" + project.getVersion() + "-unmapped.jar");
File modMappedJar = new File(libsDir, project.getName() + "-" + project.getVersion() + ".jar");
if (!modMappedJar.exists()) {
project.getLogger().error("Could not find mod jar @" + modJar.getAbsolutePath());
return;
}
if (modJar.exists()) {
modJar.delete();
}
modMappedJar.renameTo(modJar);
Path mappings = Constants.MAPPINGS_TINY.get(extension).toPath();
@ -67,9 +73,10 @@ public class ModRemapper {
TinyRemapper remapper = TinyRemapper.newRemapper()
.withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM))
.withMappings(TinyUtils.createTinyMappingProvider(Constants.MAPPINGS_MIXIN_EXPORT.get(extension).toPath(), fromM, toM))
.build();
OutputConsumerPath outputConsumer = new OutputConsumerPath(modOutputJar.toPath());
OutputConsumerPath outputConsumer = new OutputConsumerPath(modMappedJar.toPath());
outputConsumer.addNonClassFiles(modJar.toPath());
remapper.read(modJar.toPath());
remapper.read(classpath);