Skip to content

ExternalDependency and DependencyConstraint cannot be passed to DependencyResolveDetails#useTarget #36359

@octylFractal

Description

@octylFractal

Current Behavior

When running the reproducer, an error occurs:

> Could not resolve org.example:bar:1.0.0.
  Required by:
      root project 'simple-testing-project'
   > Cannot convert the provided notation to an object of type ModuleComponentSelector: junit:junit:4.13.2.
     The following types/formats are supported:
       - Instances of ModuleComponentSelector.
       - String or CharSequence values, for example 'org.gradle:gradle-core:1.0'.
       - Maps, for example [group: 'org.gradle', name:'gradle-core', version: '1.0'].
       - Version catalog type-safe accessors.

Expected Behavior

It should function as it did in 9.2.1 and prior, printing the path to the jar:

[$GRADLE_USER_HOME/caches/modules-2/files-2.1/junit/junit/4.13.2/8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12/junit-4.13.2.jar]

Context (optional)

No response

Self-contained Reproducer Project

In build.gradle.kts:

plugins {
    java
}

repositories {
    mavenCentral()
}

configurations.all {
    resolutionStrategy {
        eachDependency {
            useTarget(project.dependencies.create("junit:junit:4.13.2"))
        }
    }
}

dependencies {
    implementation("org.example:bar:1.0.0")
}

println(files(configurations["compileClasspath"]).toSet())

Run ./gradlew build.

Gradle version

9.3.0

Gradle version that used to work

9.2.1

Build scan URL (optional)

No response

Your Environment (optional)

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions