From dfacccf84fde33eb8d49a31ae1447aaa5aa83586 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Thu, 14 Jan 2021 16:05:10 +0400 Subject: [PATCH] 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 --- .../org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt | 4 ++++ .../kotlin/gradle/plugin/ProjectLocalConfigurations.kt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt index 159771ba539..d001e18345b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt @@ -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') }" ) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt index 201e7aa46d2..7b5fa05b352 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt @@ -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