Set canBeConsumed = false on the deprecated configurations like compile

This leads to cleaner error messages in Gradle variant-aware dependency
resolution failures. Gradle has deprecated those configurations since
long ago, and we didn't see much use of them as variant-aware dependency
resolution entities either.

So this commits sets `canBeConsumed` to false on these configuratons:
* compile (+ testCompile, fooCompile in MPP)
* runtime (+ testRuntime, fooRuntime, ...)
* compileOnly (+ testCompileOnly, fooCompileOnly, ...)
* default (+ fooDefault in MPP)

This change replaces the PR #3995
This commit is contained in:
Sergey Igushkin
2021-01-14 16:05:10 +04:00
committed by Space
parent 6e913e16ad
commit dfacccf84f
2 changed files with 6 additions and 0 deletions

View File

@@ -187,6 +187,10 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
with(outerProject) {
embedProject(innerProject)
gradleBuildScript().appendText(
"\nconfigurations['jvm6TestRuntime'].canBeConsumed = true"
)
gradleBuildScript(innerProject.projectName).appendText(
"\ndependencies { testCompile project(path: ':', configuration: 'jvm6TestRuntime') }"
)

View File

@@ -38,6 +38,8 @@ object ProjectLocalConfigurations {
}
internal fun Configuration.setupAsLocalTargetSpecificConfigurationIfSupported(target: KotlinTarget) {
isCanBeConsumed = false
// don't setup in old MPP common modules, as their output configurations with KotlinPlatformType attribute would
// fail to resolve as transitive dependencies of the platform modules, just as we don't mark their
// `api/RuntimeElements` with the KotlinPlatformType