Test dependencies leaked into project.getConfigurations().detachedConfiguration(deps)

Here is a snippet of code from my Gradle plugin:

    final Configuration deploymentConfig = project.getConfigurations()
            .detachedConfiguration(extensionDeps.toArray(new Dependency[0]));
    final ResolvedConfiguration rc = deploymentConfig.getResolvedConfiguration();
    for (ResolvedArtifact a : rc.getResolvedArtifacts()) {

When I use the plugin in an application, I see that there are test dependencies among the resolved artifacts, although extensionDeps don’t include those and don’t depend (at least not at compile time) on them.
My question is whether is this an expected outcome or possibly an issue in the dependency resolver in Gradle itself? Thanks.

Hi @aloubyansky,

It’s hard to say without knowing what extensionDeps contains. But the resolved artifacts will contain everything that is in there plus the artifacts from all transitive dependencies.
I am not sure what exactly you mean by “test dependencies”. But there should not be any dependencies in there that are not declared directly or transitively.

Hi @jendrik,

thanks for your response. My code snippet surely looks obscure. It’s actually from Quarkus Gradle plugin. I do understand it should return the direct plus the transitive deps, that’s what I want. However, I see dependencies of scope test (those extensionDeps are Maven artifacts) among the resolved artifacts. Is that expected?

No that is not expected. Are you sure that the dependencies are not defined again in the other places in the dependency graph with another scope?
If you can use build scans (--scan) you will also see the resolved graphs of detached configurations. This could help to understand what is going on.

@jendrik thanks a lot for your time, --scan did help catch a transitive dependency that introduced a dependency that’s supposed to be in the test scope.

1 Like