From c57799cfcb7db70b576069b1c7b7c9c660444887 Mon Sep 17 00:00:00 2001 From: Inaki Villar Date: Thu, 12 Dec 2024 00:44:09 +0100 Subject: [PATCH] avoiding calculate conditional dependencies again for the same configuration,mode and project --- ...ApplicationDeploymentClasspathBuilder.java | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java index 7fc07fdf4f152..e54be14cff418 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -228,32 +229,39 @@ private void setUpDeploymentConfiguration() { configuration.setCanBeConsumed(false); Configuration enforcedPlatforms = this.getPlatformConfiguration(); configuration.extendsFrom(enforcedPlatforms); + Map> calculatedDependenciesByModeAndConfiguration = new HashMap<>(); ListProperty dependencyListProperty = project.getObjects().listProperty(Dependency.class); configuration.getDependencies().addAllLater(dependencyListProperty.value(project.provider(() -> { - ConditionalDependenciesEnabler cdEnabler = new ConditionalDependenciesEnabler(project, mode, - enforcedPlatforms); - final Collection> allExtensions = cdEnabler.getAllExtensions(); - Set> extensions = collectFirstMetQuarkusExtensions(getRawRuntimeConfiguration(), - allExtensions); - // Add conditional extensions - for (ExtensionDependency knownExtension : allExtensions) { - if (knownExtension.isConditional()) { - extensions.add(knownExtension); + String key = String.format("%s%s%s", mode, configuration.getName(), project.getName()); + if (!calculatedDependenciesByModeAndConfiguration.containsKey(key)) { + ConditionalDependenciesEnabler cdEnabler = new ConditionalDependenciesEnabler(project, mode, + enforcedPlatforms); + final Collection> allExtensions = cdEnabler.getAllExtensions(); + Set> extensions = collectFirstMetQuarkusExtensions(getRawRuntimeConfiguration(), + allExtensions); + // Add conditional extensions + for (ExtensionDependency knownExtension : allExtensions) { + if (knownExtension.isConditional()) { + extensions.add(knownExtension); + } } - } - final Set alreadyProcessed = new HashSet<>(extensions.size()); - final DependencyHandler dependencies = project.getDependencies(); - final Set deploymentDependencies = new HashSet<>(); - for (ExtensionDependency extension : extensions) { - if (!alreadyProcessed.add(extension.getExtensionId())) { - continue; - } + final Set alreadyProcessed = new HashSet<>(extensions.size()); + final DependencyHandler dependencies = project.getDependencies(); + final Set deploymentDependencies = new HashSet<>(); + for (ExtensionDependency extension : extensions) { + if (!alreadyProcessed.add(extension.getExtensionId())) { + continue; + } - deploymentDependencies.add( - DependencyUtils.createDeploymentDependency(dependencies, extension)); + deploymentDependencies.add( + DependencyUtils.createDeploymentDependency(dependencies, extension)); + } + calculatedDependenciesByModeAndConfiguration.put(key, deploymentDependencies); + return deploymentDependencies; + } else { + return calculatedDependenciesByModeAndConfiguration.get(key); } - return deploymentDependencies; }))); }); }