Skip to content

Commit

Permalink
avoiding calculate conditional dependencies again for the same config…
Browse files Browse the repository at this point in the history
…uration,mode and project
  • Loading branch information
cdsap committed Dec 11, 2024
1 parent fc237a6 commit c57799c
Showing 1 changed file with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -228,32 +229,39 @@ private void setUpDeploymentConfiguration() {
configuration.setCanBeConsumed(false);
Configuration enforcedPlatforms = this.getPlatformConfiguration();
configuration.extendsFrom(enforcedPlatforms);
Map<String, Set<Dependency>> calculatedDependenciesByModeAndConfiguration = new HashMap<>();
ListProperty<Dependency> dependencyListProperty = project.getObjects().listProperty(Dependency.class);
configuration.getDependencies().addAllLater(dependencyListProperty.value(project.provider(() -> {
ConditionalDependenciesEnabler cdEnabler = new ConditionalDependenciesEnabler(project, mode,
enforcedPlatforms);
final Collection<ExtensionDependency<?>> allExtensions = cdEnabler.getAllExtensions();
Set<ExtensionDependency<?>> 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<ExtensionDependency<?>> allExtensions = cdEnabler.getAllExtensions();
Set<ExtensionDependency<?>> extensions = collectFirstMetQuarkusExtensions(getRawRuntimeConfiguration(),
allExtensions);
// Add conditional extensions
for (ExtensionDependency<?> knownExtension : allExtensions) {
if (knownExtension.isConditional()) {
extensions.add(knownExtension);
}
}
}

final Set<ModuleVersionIdentifier> alreadyProcessed = new HashSet<>(extensions.size());
final DependencyHandler dependencies = project.getDependencies();
final Set<Dependency> deploymentDependencies = new HashSet<>();
for (ExtensionDependency<?> extension : extensions) {
if (!alreadyProcessed.add(extension.getExtensionId())) {
continue;
}
final Set<ModuleVersionIdentifier> alreadyProcessed = new HashSet<>(extensions.size());
final DependencyHandler dependencies = project.getDependencies();
final Set<Dependency> 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;
})));
});
}
Expand Down

0 comments on commit c57799c

Please sign in to comment.