-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
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).
Line 166 in 84bb123
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.Line 102 in 84bb123
for (ConfigurationInternal configuration : configurationsProvider.getAll()) {
when we actually select the configuration here
, we get noLine 137 in 84bb123
Optional<ImmutableList<? extends ConfigurationMetadata>> targetVariants = targetComponent.getVariantsForGraphTraversal(); targetVariantsbecause that sole configuration is not consumable as described hereLine 231 in 84bb123
ImmutableList.Builder<ConfigurationMetadata> builder = new ImmutableList.Builder<ConfigurationMetadata>();
useConfigurationAttributesis thus false, and we try to get thedefaultconfiguration 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,
useConfigurationAttributesis true, and we getapiElementsas the selected configuration and everything works.