KT-59304 Elevate warning to Error for pre-HMPP flags
Flag `kotlin.mpp.deprecatedProperties.nowarn` was removed. Diagnostic could be temporarily suppressed by the: kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
This commit is contained in:
committed by
teamcity
parent
cfcb0690d7
commit
fcd440fd9e
+6
@@ -951,6 +951,12 @@ abstract class BaseGradleIT {
|
||||
add("--${options.stacktraceMode}")
|
||||
}
|
||||
|
||||
// temporary suppression for the usage of deprecated pre-HMPP properties.
|
||||
// Should be removed together with the flags support in 2.0
|
||||
if (options.hierarchicalMPPStructureSupport != null || options.enableCompatibilityMetadataVariant != null) {
|
||||
add("-Pkotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError")
|
||||
}
|
||||
|
||||
// Workaround: override a console type set in the user machine gradle.properties (since Gradle 4.3):
|
||||
add("--console=plain")
|
||||
//The feature of failing the build on deprecation warnings is introduced in gradle 5.6
|
||||
|
||||
+4
-2
@@ -396,7 +396,9 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
beforePublishing()
|
||||
|
||||
if (!withGranularMetadata) {
|
||||
projectPath.toFile().resolve("gradle.properties").appendText("kotlin.internal.mpp.hierarchicalStructureByDefault=false")
|
||||
val gradleProperties = projectPath.toFile().resolve("gradle.properties")
|
||||
gradleProperties.appendText("kotlin.internal.mpp.hierarchicalStructureByDefault=false${System.lineSeparator()}")
|
||||
gradleProperties.appendText("kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError${System.lineSeparator()}")
|
||||
}
|
||||
build("publish")
|
||||
}
|
||||
@@ -620,7 +622,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
"transformCommonMainDependenciesMetadata",
|
||||
"transformJvmAndJsMainDependenciesMetadata",
|
||||
"transformLinuxAndJsMainDependenciesMetadata",
|
||||
"compileKotlinMetadata",
|
||||
"compileCommonMainKotlinMetadata",
|
||||
"compileJvmAndJsMainKotlinMetadata",
|
||||
"compileLinuxAndJsMainKotlinMetadata"
|
||||
).map { task -> subprojectPrefix?.let { ":$it" }.orEmpty() + ":" + task }
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ internal class HierarchicalStructureOptInMigrationArtifactContentMppIT : BaseGra
|
||||
*buildList {
|
||||
add("clean")
|
||||
add("publish")
|
||||
add("-Pkotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError")
|
||||
when (mode) {
|
||||
OPT_OUT_HMPP, HMPP_BY_DEFAULT -> {}
|
||||
DISABLE_HMPP_BY_DEFAULT -> { add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=false") }
|
||||
|
||||
+1
-1
@@ -330,8 +330,8 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
|
||||
projectDir.resolve("gradle.properties").appendText(
|
||||
"\n" + """
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ class MppDiagnosticsIt : KGPBaseTest() {
|
||||
this.buildGradleKts.writeText("")
|
||||
checkDeprecatedProperties(isDeprecationExpected = true)
|
||||
|
||||
this.gradleProperties.appendText("kotlin.mpp.deprecatedProperties.nowarn=true${System.lineSeparator()}")
|
||||
this.gradleProperties.appendText("kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError${System.lineSeparator()}")
|
||||
checkDeprecatedProperties(isDeprecationExpected = false)
|
||||
}
|
||||
}
|
||||
@@ -196,9 +196,9 @@ class MppDiagnosticsIt : KGPBaseTest() {
|
||||
private fun TestProject.checkDeprecatedProperties(isDeprecationExpected: Boolean) {
|
||||
build {
|
||||
if (isDeprecationExpected)
|
||||
output.assertHasDiagnostic(KotlinToolingDiagnostics.HierarchicalMultiplatformFlagsWarning)
|
||||
output.assertHasDiagnostic(KotlinToolingDiagnostics.PreHMPPFlagsError)
|
||||
else
|
||||
output.assertNoDiagnostic(KotlinToolingDiagnostics.HierarchicalMultiplatformFlagsWarning)
|
||||
output.assertNoDiagnostic(KotlinToolingDiagnostics.PreHMPPFlagsError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
> Configure project :
|
||||
|
||||
> Configure project :subprojectA
|
||||
w: [HierarchicalMultiplatformFlagsWarning | WARNING] The following properties are obsolete and will be removed in Kotlin 1.9.20:
|
||||
e: [PreHMPPFlagsError | ERROR] The following properties are obsolete and no longer supported:
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant, kotlin.mpp.hierarchicalStructureSupport
|
||||
Read the details here: https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties
|
||||
#diagnostic-end
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+1
@@ -1 +1,2 @@
|
||||
kotlin.internal.mpp.hierarchicalStructureByDefault=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+1
@@ -1 +1,2 @@
|
||||
kotlin.internal.mpp.hierarchicalStructureByDefault=false
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
+1
@@ -1 +1,2 @@
|
||||
kotlin.internal.mpp.hierarchicalStructureByDefault=false
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
|
||||
-5
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLI
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_ANDROID_STYLE_NO_WARN
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_VERSION
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_APPLY_DEFAULT_HIERARCHY_TEMPLATE
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_DEPRECATED_PROPERTIES_NO_WARN
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA
|
||||
@@ -263,9 +262,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val ignoreIncorrectNativeDependencies: Boolean?
|
||||
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES)
|
||||
|
||||
val ignoreHmppDeprecationWarnings: Boolean?
|
||||
get() = booleanProperty(KOTLIN_MPP_DEPRECATED_PROPERTIES_NO_WARN)
|
||||
|
||||
val publishJvmEnvironmentAttribute: Boolean
|
||||
get() = booleanProperty(KOTLIN_PUBLISH_JVM_ENVIRONMENT_ATTRIBUTE) ?: false
|
||||
|
||||
@@ -622,7 +618,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT = property("kotlin.mpp.enableCompatibilityMetadataVariant")
|
||||
val KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION = property("kotlin.mpp.enableCInteropCommonization")
|
||||
val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT = property("kotlin.mpp.hierarchicalStructureSupport")
|
||||
val KOTLIN_MPP_DEPRECATED_PROPERTIES_NO_WARN = property("kotlin.mpp.deprecatedProperties.nowarn")
|
||||
val KOTLIN_MPP_ANDROID_GRADLE_PLUGIN_COMPATIBILITY_NO_WARN = property("kotlin.mpp.androidGradlePluginCompatibility.nowarn")
|
||||
val KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_VERSION = property("kotlin.mpp.androidSourceSetLayoutVersion")
|
||||
val KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_ANDROID_STYLE_NO_WARN = property("kotlin.mpp.androidSourceSetLayoutV2AndroidStyleDirs.nowarn")
|
||||
|
||||
+9
-2
@@ -22,9 +22,16 @@ import org.jetbrains.kotlin.gradle.plugin.sources.android.multiplatformAndroidSo
|
||||
|
||||
@InternalKotlinGradlePluginApi // used in integration tests
|
||||
object KotlinToolingDiagnostics {
|
||||
object HierarchicalMultiplatformFlagsWarning : ToolingDiagnosticFactory(WARNING) {
|
||||
/**
|
||||
* This diagnostic is suppressed in kotlin-test and kotlin-stdlib.
|
||||
* We should migrate the stdlib and kotlin-test from deprecated flags and then completely remove the support.
|
||||
* ETA: 2.0-M1
|
||||
*
|
||||
* P.s. Some tests also suppress this diagnostic -- these tests should be removed together with the flags support
|
||||
*/
|
||||
object PreHMPPFlagsError : ToolingDiagnosticFactory(ERROR) {
|
||||
operator fun invoke(usedDeprecatedFlags: List<String>) = build(
|
||||
"The following properties are obsolete and will be removed in Kotlin 1.9.20:\n" +
|
||||
"The following properties are obsolete and no longer supported:\n" +
|
||||
"${usedDeprecatedFlags.joinToString()}\n" +
|
||||
"Read the details here: https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties",
|
||||
)
|
||||
|
||||
+1
-2
@@ -27,7 +27,6 @@ internal fun runDeprecationDiagnostics(project: Project) {
|
||||
*/
|
||||
private fun checkAndReportDeprecatedMppProperties(project: Project) {
|
||||
val projectProperties = project.kotlinPropertiesProvider
|
||||
if (projectProperties.ignoreHmppDeprecationWarnings == true) return
|
||||
|
||||
val usedProperties = deprecatedMppProperties.mapNotNull { propertyName ->
|
||||
if (propertyName in propertiesSetByPlugin && projectProperties.mpp13XFlagsSetByPlugin)
|
||||
@@ -41,7 +40,7 @@ private fun checkAndReportDeprecatedMppProperties(project: Project) {
|
||||
|
||||
project.kotlinToolingDiagnosticsCollector.reportOncePerGradleBuild(
|
||||
project,
|
||||
KotlinToolingDiagnostics.HierarchicalMultiplatformFlagsWarning(usedProperties)
|
||||
KotlinToolingDiagnostics.PreHMPPFlagsError(usedProperties)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -8,10 +8,9 @@
|
||||
package org.jetbrains.kotlin.gradle.regressionTests
|
||||
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.util.applyMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.util.buildProject
|
||||
import org.jetbrains.kotlin.gradle.util.enableCompatibilityMetadataVariant
|
||||
import org.jetbrains.kotlin.gradle.util.kotlin
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -19,7 +18,11 @@ class KT55730CommonMainDependsOnAnotherSourceSet {
|
||||
@Test
|
||||
fun `legacy metadata compilation should have commonMain with its depends on closure`() {
|
||||
val project = buildProject {
|
||||
enableCompatibilityMetadataVariant()
|
||||
propertiesExtension.set(PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT, "true")
|
||||
propertiesExtension.set(
|
||||
PropertiesProvider.PropertyNames.KOTLIN_SUPPRESS_GRADLE_PLUGIN_ERRORS,
|
||||
KotlinToolingDiagnostics.PreHMPPFlagsError.id
|
||||
)
|
||||
applyMultiplatformPlugin()
|
||||
kotlin {
|
||||
val grandCommonMain = sourceSets.create("grandCommonMain")
|
||||
|
||||
-4
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_INTRANSITIVE_METADATA_CONFIGURATION
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.getExtension
|
||||
@@ -133,6 +132,3 @@ fun Project.enableDependencyVerification(enabled: Boolean = true) {
|
||||
else DependencyVerificationMode.OFF
|
||||
}
|
||||
|
||||
fun Project.enableCompatibilityMetadataVariant(enabled: Boolean = true) {
|
||||
propertiesExtension.set(KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT, enabled.toString())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user