Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to find dependencies due to the aggregateConfiguration created in DependencyLockTaskConfigurer #277

Open
LanceNeumannBlackboard opened this issue Jan 18, 2025 · 0 comments

Comments

@LanceNeumannBlackboard
Copy link

LanceNeumannBlackboard commented Jan 18, 2025

I'm trying to upgrade from Gradle 7.6.4 to 8.11.1 and as part of that it appears as though I have to upgrade the gradle-dependency-lock-plugin which was on 9.4.1. The problem is that the newer versions all fail in the generateGlobalLock task with an error of
...
Caused by: org.gradle.api.internal.artifacts.ivyservice.TypedResolveException: Could not resolve all dependencies for configuration ':detachedConfiguration1'.
...
Caused by: org.gradle.internal.component.resolution.failure.exception.VariantSelectionByNameException: A dependency was declared on configuration 'aggregateConfiguration' of 'project :the:project-name' but no variant with that configuration name exists.
....

I tracked this down to a change that was made in DependencyLockTaskConfigurer.groovy in d482515#diff-baa5044cd9d9bfebb1f37a3a4ad6b512462b4fd94ac6400393c6671623287416

If I modify a local copy of the dependency-lock plugin by reverting this code with the following diff then everything works properly. I assume this change was originally done for a reason. Any chance you would consider adding an option to conditionally use the non-aggregate way of collecting these dependencies?

Our build does have a custom resolution strategy defined via configurations {... all { resolutionStrategy { which is lost in that aggregate configuration (or more specifically: logging in that resolutionStrategy is never hit when using aggregate but is when using a direct dependency as it used to be pre-2021). Maybe that is related to the issue with the aggregateConfiguration?

diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy
index 02484e6..9be9924 100644
--- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy
+++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy
@@ -260,18 +260,14 @@ class DependencyLockTaskConfigurer {
                         if (ext != null) {
                             Collection<Configuration> lockableConfigurations = lockableConfigurations(project, subproject, ext.configurationNames, extension.skippedConfigurationNamesPrefixes)
                             Collection<Configuration> configurations = filterNonLockableConfigurationsAndProvideWarningsForGlobalLockSubproject(subproject, ext.configurationNames, lockableConfigurations)
-                            Configuration aggregate = subproject.configurations.create("aggregateConfiguration")
-                            aggregate.setCanBeConsumed(true)
-                            aggregate.setCanBeResolved(true)
                             configurations
                                     .findAll { configuration ->
                                         !configurationsToSkipForGlobalLockPrefixes.any { String prefix -> configuration.name.startsWith(prefix) }
                                                 && !extension.skippedConfigurationNamesPrefixes.any { String prefix -> configuration.name.startsWith(prefix) }
                                     }
-                                    .each { configuration ->
-                                        aggregate.extendsFrom(configuration)
+                                    .collect { configuration ->
+                                        project.dependencies.create(project.dependencies.project(path: subproject.path, configuration: configuration.name))
                                     }
-                            [project.dependencies.create(project.dependencies.project(path: subproject.path, configuration: aggregate.name))]
                         } else {
                             [project.dependencies.create(subproject)]
                         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant