more gradle fixes

dev/0.11
asie 2018-12-31 00:42:49 +01:00
parent 6749c9688e
commit e038abcb8e
5 changed files with 33 additions and 11 deletions

View File

@ -80,6 +80,8 @@ public class AbstractPlugin implements Plugin<Project> {
Configuration compileModsConfig = project.getConfigurations().maybeCreate(Constants.COMPILE_MODS); Configuration compileModsConfig = project.getConfigurations().maybeCreate(Constants.COMPILE_MODS);
compileModsConfig.setTransitive(false); // Dont get transitive deps of mods compileModsConfig.setTransitive(false); // Dont get transitive deps of mods
Configuration compileModsMappedConfig = project.getConfigurations().maybeCreate(Constants.COMPILE_MODS_MAPPED);
compileModsMappedConfig.setTransitive(false); // Dont get transitive deps of mods
Configuration minecraftNamedConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_NAMED); Configuration minecraftNamedConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_NAMED);
minecraftNamedConfig.setTransitive(false); // The launchers do not recurse dependencies minecraftNamedConfig.setTransitive(false); // The launchers do not recurse dependencies
Configuration minecraftIntermediaryConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_INTERMEDIARY); Configuration minecraftIntermediaryConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_INTERMEDIARY);
@ -94,6 +96,15 @@ public class AbstractPlugin implements Plugin<Project> {
configureIDEs(); configureIDEs();
configureCompile(); configureCompile();
extendsFrom(Constants.MINECRAFT_NAMED, Constants.MINECRAFT_DEPENDENCIES);
extendsFrom(Constants.MINECRAFT_INTERMEDIARY, Constants.MINECRAFT_DEPENDENCIES);
extendsFrom(Constants.COMPILE_MODS_MAPPED, Constants.MINECRAFT_NAMED);
extendsFrom("compile", Constants.COMPILE_MODS_MAPPED);
extendsFrom("compile", Constants.MAPPINGS);
extendsFrom("annotationProcessor", Constants.COMPILE_MODS_MAPPED);
extendsFrom("annotationProcessor", Constants.MAPPINGS);
Map<Project, Set<Task>> taskMap = project.getAllTasks(true); Map<Project, Set<Task>> taskMap = project.getAllTasks(true);
for (Map.Entry<Project, Set<Task>> entry : taskMap.entrySet()) { for (Map.Entry<Project, Set<Task>> entry : taskMap.entrySet()) {
Project project = entry.getKey(); Project project = entry.getKey();
@ -243,13 +254,6 @@ public class AbstractPlugin implements Plugin<Project> {
handler.add("annotationProcessor", "net.fabricmc:sponge-mixin:" + extension.getMixinVersion()); handler.add("annotationProcessor", "net.fabricmc:sponge-mixin:" + extension.getMixinVersion());
handler.add("annotationProcessor", "net.fabricmc:fabric-loom:" + extension.getLoomVersion()); handler.add("annotationProcessor", "net.fabricmc:fabric-loom:" + extension.getLoomVersion());
extendsFrom(Constants.MINECRAFT_NAMED, Constants.MINECRAFT_DEPENDENCIES);
extendsFrom(Constants.COMPILE_MODS, Constants.MINECRAFT_NAMED);
extendsFrom("compile", Constants.COMPILE_MODS);
extendsFrom("compile", Constants.MAPPINGS);
extendsFrom("annotationProcessor", Constants.COMPILE_MODS);
extendsFrom("annotationProcessor", Constants.MAPPINGS);
// Enables the default mod remapper // Enables the default mod remapper
if (extension.remapMod) { if (extension.remapMod) {
AbstractArchiveTask jarTask = (AbstractArchiveTask) project1.getTasks().getByName("jar"); AbstractArchiveTask jarTask = (AbstractArchiveTask) project1.getTasks().getByName("jar");

View File

@ -62,7 +62,7 @@ public class ModRemapperProvider extends DependencyProvider {
throw new RuntimeException("Failed to remap mod"); throw new RuntimeException("Failed to remap mod");
} }
project.getDependencies().add(Constants.COMPILE_MODS, project.getDependencies().module( project.getDependencies().add(Constants.COMPILE_MODS_MAPPED, project.getDependencies().module(
rds + verSuffix rds + verSuffix
)); ));

View File

@ -36,6 +36,7 @@ public class Constants {
public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32"; public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32";
public static final String COMPILE_MODS = "modCompile"; public static final String COMPILE_MODS = "modCompile";
public static final String COMPILE_MODS_MAPPED = "modCompileMapped";
public static final String MINECRAFT = "minecraft"; public static final String MINECRAFT = "minecraft";
public static final String MINECRAFT_DEPENDENCIES = "minecraftLibraries"; public static final String MINECRAFT_DEPENDENCIES = "minecraftLibraries";
public static final String MINECRAFT_INTERMEDIARY = "minecraftIntermediary"; public static final String MINECRAFT_INTERMEDIARY = "minecraftIntermediary";

View File

@ -60,9 +60,19 @@ public class ModRemapper {
String toM = "intermediary"; String toM = "intermediary";
List<File> classpathFiles = new ArrayList<>(); List<File> classpathFiles = new ArrayList<>();
classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles()); // classpathFiles.addAll(project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.MINECRAFT_INTERMEDIARY).getFiles());
Path[] classpath = classpathFiles.stream().map(File::toPath).toArray(Path[]::new); Path[] classpath = classpathFiles.stream().map(File::toPath).toArray(Path[]::new);
Path modJarPath = modJar.toPath(); Path modJarPath = modJar.toPath();
boolean classpathContainsModJarPath = false;
for (Path p : classpath) {
if (modJarPath.equals(p)) {
modJarPath = p;
classpathContainsModJarPath = true;
break;
}
}
String s =modJar.getAbsolutePath(); String s =modJar.getAbsolutePath();
File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar"); File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar");
@ -89,7 +99,9 @@ public class ModRemapper {
try (OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath)) { try (OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath)) {
outputConsumer.addNonClassFiles(modJarPath); outputConsumer.addNonClassFiles(modJarPath);
remapper.read(classpath); remapper.read(classpath);
remapper.read(modJarPath); if (!classpathContainsModJarPath) {
remapper.read(modJarPath);
}
remapper.apply(modJarPath, outputConsumer); remapper.apply(modJarPath, outputConsumer);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to remap JAR", e); throw new RuntimeException("Failed to remap JAR", e);

View File

@ -77,9 +77,14 @@ public class SourceRemapper {
Mercury mercury = new Mercury(); Mercury mercury = new Mercury();
for (File file : project.getConfigurations().getByName("compile").getFiles()) { for (File file : project.getConfigurations().getByName(Constants.MINECRAFT_DEPENDENCIES).getFiles()) {
mercury.getClassPath().add(file.toPath()); mercury.getClassPath().add(file.toPath());
} }
if (!toNamed) {
for (File file : project.getConfigurations().getByName(Constants.COMPILE_MODS_MAPPED).getFiles()) {
mercury.getClassPath().add(file.toPath());
}
}
for (File file : extension.getUnmappedMods()) { for (File file : extension.getUnmappedMods()) {
if (file.isFile()) { if (file.isFile()) {
mercury.getClassPath().add(file.toPath()); mercury.getClassPath().add(file.toPath());