Skip to content

JVM Test Suit does not allow adding dependencies if there's build logic iterating over declared dependencies #28867

@ALikhachev

Description

@ALikhachev

Current Behavior

Such build logic makes adding dependencies to a test suit impossible:

configurations.configureEach {
    if (isCanBeResolved && !isCanBeConsumed) {
        allDependencies.configureEach { // <-- removing this logic solves the problem

        }
    }
}

Project configuration fails with

FAILURE: Build failed with an exception.

* Where:
Build file '[redacted]/test-suites-dependencies/build.gradle.kts' line: 26

* What went wrong:
Could not create domain object 'myAwesomeTests' (JvmTestSuite)
> The value for property 'dependencies.implementation' property 'dependencies' is final and cannot be changed any further.

Expected Behavior

It's possible to iterate over declared dependencies and add dependencies to test suites, or at least the error message is not so cryptic and more actionable

Context (optional)

We use such build logic in the Kotlin repo to add dependency constrains dynamically via a convention plugin

This used to work on Gradle versions below 8.6

Steps to Reproduce

https://github.com/ALikhachev/gradle-reproducers/tree/main/test-suites-dependencies

Gradle version

8.6, 8.7

Gradle version that used to work

8.5

Build scan URL (optional)

No response

Your Environment (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed:not-fixedIndicates the issue was not fixed and is not planned to be

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions