How to link a ResolvedArtifactResult back to its source Dependency?

Hi,

Given these configurations:

configurations {
    bag1 {
        canBeResolved = false
        canBeConsumed = false
    }

    bag2 {
        canBeConsumed = false
        extendsFrom bag1
    }
}

we have previously been using Gradle’s

ResolvedConfiguration.getFirstLevelModuleDependencies(Spec<? super Dependency> spec)

API so that our plugin can determine the Set<ResolvedArtifact> that bag1 contributes when we resolve bag2.

This was all fine until Gradle’s configuration cache decided to forbid a task from resolving a Configuration object into a ResolvedConfiguration object at execution time.

The “lazy” way to resolve a Configuration seems to be Configuration.getIncoming(), whose Javadoc reads:

Returns the incoming dependencies of this configuration.

:roll_eyes:

However, while this API returns an ArtifactCollection, I cannot find any way to link any of its ResolvedArtifactResult objects back to a Dependency in the same way that ResolvedConfiguration could for its ResolvedArtifact objects.

Am I missing something here? Can anyone help please?
Thanks for any assistance,
Cheers,
Chris