fix mod compilation

dev/0.11
Adrian Siekierka 2018-11-02 10:33:03 +01:00
parent e05aae6cd8
commit 6b17d207d5
4 changed files with 15 additions and 9 deletions

View File

@ -105,6 +105,7 @@ public class AbstractPlugin implements Plugin<Project> {
javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args");
try {
javaCompileTask.getClasspath().add(project.getConfigurations().getByName(Constants.CONFIG_MINECRAFT));
javaCompileTask.getClasspath().add(target.files(this.getClass().getProtectionDomain().getCodeSource().getLocation()));
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFilePomfIntermediary=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath());

View File

@ -43,6 +43,7 @@ public class SetupTask extends DefaultTask {
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 -> {

View File

@ -65,7 +65,6 @@ public class Constants {
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-libs"));
public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-natives"));
public static final IDelayed<File> MINECRAFT_JSON = new DelayedFile(extension -> new File(extension.getUserCache(), extension.version + "-info.json"));
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(CACHE_FILES, "mixin-refmap.json"));
public static final IDelayed<File> VERSION_MANIFEST = new DelayedFile(extension -> new File(extension.getUserCache(), "version_manifest.json"));

View File

@ -53,10 +53,7 @@ import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@ -83,9 +80,13 @@ public class ModProcessor {
File mappingsFile = Constants.MAPPINGS_TINY.get(extension);
Path mappings = mappingsFile.toPath();
Path mc = Constants.MINECRAFT_INTERMEDIARY_JAR.get(extension).toPath();
Path[] classpath = project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles().stream()
Path[] mcDeps = project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles().stream()
.map(File::toPath)
.toArray(Path[]::new);
Collection<File> modCompileFiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles();
Path[] modCompiles = modCompileFiles.stream()
.map(File::toPath)
.toArray(Path[]::new);
project.getLogger().lifecycle(":remapping " + input.getName() + " (TinyRemapper, " + fromM + " -> " + toM + ")");
@ -96,9 +97,12 @@ public class ModProcessor {
try {
OutputConsumerPath outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()));
outputConsumer.addNonClassFiles(input.toPath());
remapper.read(input.toPath());
if (!modCompileFiles.contains(input)) {
remapper.read(input.toPath());
}
remapper.read(modCompiles);
remapper.read(mc);
remapper.read(classpath);
remapper.read(mcDeps);
remapper.apply(input.toPath(), outputConsumer);
outputConsumer.finish();
} catch (Exception e){
@ -110,7 +114,6 @@ public class ModProcessor {
}
Gson gson = new GsonBuilder().setPrettyPrinting().create();
project.getLogger().lifecycle(":remapping " + input.getName() + " (Mixin reference map)");
// first, identify all of the mixin refmaps
Set<String> mixinRefmapFilenames = new HashSet<>();
// TODO: this is a lovely hack
@ -139,6 +142,8 @@ public class ModProcessor {
throw new RuntimeException(e);
}
project.getLogger().lifecycle(":remapping " + input.getName() + " (Mixin reference maps)");
ZipUtil.transformEntries(
output,
mixinRefmapFilenames.stream()