diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppDeprecatedPropertiesIt.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppDeprecatedPropertiesIt.kt index 84f632125b0..579346fdaba 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppDeprecatedPropertiesIt.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppDeprecatedPropertiesIt.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.mpp import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.testbase.* import kotlin.io.path.appendText +import kotlin.io.path.writeText import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -27,6 +28,10 @@ class MppDeprecatedPropertiesIt : KGPBaseTest() { ) checkDeprecations(isDeprecationExpected = true) + // remove the MPP plugin from the top-level project and check the warnings are still reported in subproject + this.buildGradleKts.writeText("") + checkDeprecations(isDeprecationExpected = true) + this.gradleProperties.appendText("kotlin.mpp.deprecatedProperties.nowarn=true${System.lineSeparator()}") checkDeprecations(isDeprecationExpected = false) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/deprecationDiagnostics.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/deprecationDiagnostics.kt index a0fd02168de..4a6d2e39661 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/deprecationDiagnostics.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/deprecationDiagnostics.kt @@ -38,12 +38,13 @@ internal fun checkAndReportDeprecatedNativeTargets(project: Project) { * Warnings have to be reported only for successfully evaluated projects without errors. */ internal fun checkAndReportDeprecatedMppProperties(project: Project) { - if (project !== project.rootProject) return - val projectProperties = project.kotlinPropertiesProvider if (projectProperties.ignoreHmppDeprecationWarnings == true) return val warnings = deprecatedMppProperties.mapNotNull { propertyName -> + if (propertyName in propertiesSetByPlugin && projectProperties.mpp13XFlagsSetByPlugin) + return@mapNotNull null + @OptIn(UnsafeApi::class) projectProperties.property(propertyName)?.let { getMppDeprecationWarningMessageForProperty(propertyName) } } @@ -65,6 +66,11 @@ internal val deprecatedMppProperties: List = listOf( KOTLIN_NATIVE_DEPENDENCY_PROPAGATION, ) +private val propertiesSetByPlugin: Set = setOf( + KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA, + KOTLIN_NATIVE_DEPENDENCY_PROPAGATION, +) + internal fun getMppDeprecationWarningMessageForProperty(property: String): String = "w: The property '$property' is obsolete and will be removed in Kotlin 1.9. Read the details here: " + "https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties"