Skip to content

Cannot resolve a dependency on the root project in a detached configuration #9591

@isker

Description

@isker

Simply as the title says. Resolution of a detached configuration with a dependency on a project (apparently only the root project; subprojects must be a different code path) always fails. Here's a reproducer https://github.com/isker/detached-configuration-project-dependency showing how a detached configuration fails while an attached one succeeds.

Context

Trying to use detached configurations as intended: for resolving dependencies internal to a task.

Steps to Reproduce

Your Environment

See linked repo.

My analysis of why this fails in Slack: https://gradle-community.slack.com/archives/CA7UM03V3/p1559326205034400?thread_ts=1559316610.030100&cid=CA7UM03V3

Copied here for permanence:

we create the detached configuration. it gets this special DetachedConfigurationsProvider that provides precisely one configuration (the one we created).

rootComponentMetadataBuilder.withConfigurationsProvider(detachedConfigurationsProvider), documentationRegistry, userCodeApplicationContext, new DomainObjectProjectStateHandler(projectStateRegistry, context, projectFinder), domainObjectCollectionFactory);

when we go to resolve, that provider travels down the call stack to here

where it provides the sole configuration to this RootLocalComponentMetadata.

when we actually select the configuration here

Optional<ImmutableList<? extends ConfigurationMetadata>> targetVariants = targetComponent.getVariantsForGraphTraversal();
, we get no targetVariants because that sole configuration is not consumable as described here
ImmutableList.Builder<ConfigurationMetadata> builder = new ImmutableList.Builder<ConfigurationMetadata>();

useConfigurationAttributes is thus false, and we try to get the default configuration on line 143, which does not exist for the same reason (we only have our one detached configuration), thus we get this exception.

if we repeat this entire exercise with a regular attached configuration, useConfigurationAttributes is true, and we get apiElements as the selected configuration and everything works.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions