Make all loom added configurations lazy

dev/0.11
modmuss50 2021-05-04 20:06:24 +01:00
parent f4f660dce5
commit 927180e36b
1 changed files with 17 additions and 25 deletions

View File

@ -25,7 +25,7 @@
package net.fabricmc.loom.configuration; package net.fabricmc.loom.configuration;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
@ -47,32 +47,24 @@ public final class CompileConfiguration {
} }
public static void setupConfigurations(Project project) { public static void setupConfigurations(Project project) {
Configuration modCompileClasspathConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MOD_COMPILE_CLASSPATH); final ConfigurationContainer configurations = project.getConfigurations();
modCompileClasspathConfig.setTransitive(true); LoomProjectData data = project.getExtensions().getByType(LoomGradleExtension.class).getProjectData();
Configuration modCompileClasspathMappedConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED);
modCompileClasspathMappedConfig.setTransitive(false);
Configuration minecraftNamedConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT_NAMED); data.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH).configure(configuration -> configuration.setTransitive(true));
minecraftNamedConfig.setTransitive(false); // The launchers do not recurse dependencies data.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED).configure(configuration -> configuration.setTransitive(false));
Configuration minecraftDependenciesConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT_DEPENDENCIES); data.createLazyConfiguration(Constants.Configurations.MINECRAFT_NAMED).configure(configuration -> configuration.setTransitive(false)); // The launchers do not recurse dependencies
minecraftDependenciesConfig.setTransitive(false); data.createLazyConfiguration(Constants.Configurations.MINECRAFT_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
Configuration loaderDependenciesConfig = project.getConfigurations().maybeCreate(Constants.Configurations.LOADER_DEPENDENCIES); data.createLazyConfiguration(Constants.Configurations.LOADER_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
loaderDependenciesConfig.setTransitive(false); data.createLazyConfiguration(Constants.Configurations.MINECRAFT).configure(configuration -> configuration.setTransitive(false));
Configuration minecraftConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT); data.createLazyConfiguration(Constants.Configurations.INCLUDE).configure(configuration -> configuration.setTransitive(false)); // Dont get transitive deps
minecraftConfig.setTransitive(false); data.createLazyConfiguration(Constants.Configurations.MAPPING_CONSTANTS);
Configuration includeConfig = project.getConfigurations().maybeCreate(Constants.Configurations.INCLUDE);
includeConfig.setTransitive(false); // Dont get transitive deps
project.getConfigurations().maybeCreate(Constants.Configurations.MAPPING_CONSTANTS);
extendsFrom(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Configurations.MAPPING_CONSTANTS, project); extendsFrom(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Configurations.MAPPING_CONSTANTS, project);
project.getConfigurations().maybeCreate(Constants.Configurations.MAPPINGS); data.createLazyConfiguration(Constants.Configurations.MAPPINGS);
project.getConfigurations().maybeCreate(Constants.Configurations.MAPPINGS_FINAL); data.createLazyConfiguration(Constants.Configurations.MAPPINGS_FINAL);
project.getConfigurations().maybeCreate(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES); data.createLazyConfiguration(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
project.getConfigurations().maybeCreate(Constants.Configurations.UNPICK_CLASSPATH); data.createLazyConfiguration(Constants.Configurations.UNPICK_CLASSPATH);
LoomProjectData data = project.getExtensions().getByType(LoomGradleExtension.class).getProjectData();
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) { for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
data.createLazyConfiguration(entry.getSourceConfiguration()) data.createLazyConfiguration(entry.getSourceConfiguration())
@ -82,7 +74,7 @@ public final class CompileConfiguration {
data.createLazyConfiguration(entry.getRemappedConfiguration()) data.createLazyConfiguration(entry.getRemappedConfiguration())
.configure(configuration -> configuration.setTransitive(false)); .configure(configuration -> configuration.setTransitive(false));
extendsFrom(entry.getTargetConfiguration(project.getConfigurations()), entry.getRemappedConfiguration(), project); extendsFrom(entry.getTargetConfiguration(configurations), entry.getRemappedConfiguration(), project);
if (entry.isOnModCompileClasspath()) { if (entry.isOnModCompileClasspath()) {
extendsFrom(Constants.Configurations.MOD_COMPILE_CLASSPATH, entry.getSourceConfiguration(), project); extendsFrom(Constants.Configurations.MOD_COMPILE_CLASSPATH, entry.getSourceConfiguration(), project);
@ -166,6 +158,6 @@ public final class CompileConfiguration {
} }
private static void extendsFrom(String a, String b, Project project) { private static void extendsFrom(String a, String b, Project project) {
project.getConfigurations().getByName(a).extendsFrom(project.getConfigurations().getByName(b)); project.getConfigurations().getByName(a, configuration -> configuration.extendsFrom(project.getConfigurations().getByName(b)));
} }
} }