-
Notifications
You must be signed in to change notification settings - Fork 4
Description
It's done during task configuration for it to be done "late". The reason for that decision was that users may re-configure a test suite between the different modes – WHITEBOX, CLASSPATH, BLACKBOX. And this should only be done for WHITEBOX, which is the default for test sets without module-info.
However, doing it like this may cause the following warning:
Mutating a configuration after it has been resolved, consumed as a variant, or used for generating published metadata. This behavior has been deprecated.
This will fail with an error in Gradle 9.0.
After a configuration has been observed, it should not be modified.
https://scans.gradle.com/s/ebi3zstoepr22/deprecations?expanded=WyI0Il0
Workaround is to explicitly define the extendsFrom
in the build. Then the plugin won't do it again:
configurations.compileOnlyTest { extendsFrom(configurations.compileOnly.get()) }
I think the best solution it to add the extendsFrom
directly and remove it again on test suite re-configuration.
Code to be adjusted:
java-module-testing/src/main/java/org/gradlex/javamodule/testing/JavaModuleTestingExtension.java
Lines 211 to 215 in a508f05
Configuration compileOnly = configurations.getByName(sourcesUnderTest.getCompileOnlyConfigurationName()); | |
Configuration testCompileOnly = configurations.getByName(testSources.getCompileOnlyConfigurationName()); | |
if (!testCompileOnly.getExtendsFrom().contains(compileOnly)) { | |
testCompileOnly.extendsFrom(compileOnly); | |
} |