Create checker for deprecated gradle properties
#KT-64380 Fixed
This commit is contained in:
committed by
Space Team
parent
65cfc578a8
commit
a7f57710e2
+10
@@ -808,6 +808,16 @@ object KotlinToolingDiagnostics {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object DeprecatedGradleProperties : ToolingDiagnosticFactory(WARNING) {
|
||||||
|
operator fun invoke(usedDeprecatedProperties: List<String>): ToolingDiagnostic {
|
||||||
|
return build(
|
||||||
|
"""
|
||||||
|
$usedDeprecatedProperties properties were deprecated and are not supported anymore. Please, delete them from project properties.
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.indentLines(nSpaces: Int = 4, skipFirstLine: Boolean = true): String {
|
private fun String.indentLines(nSpaces: Int = 4, skipFirstLine: Boolean = true): String {
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesBuildService
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectCheckerContext
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnosticsCollector
|
||||||
|
|
||||||
|
internal object GradleDeprecatedPropertyChecker : KotlinGradleProjectChecker {
|
||||||
|
private val deprecatedProperties: List<String> = listOf(
|
||||||
|
"kotlin.useK2",
|
||||||
|
"kotlin.experimental.tryK2",
|
||||||
|
"kapt.use.k2",
|
||||||
|
"kotlin.internal.single.build.metrics.file",
|
||||||
|
"kotlin.build.report.dir"
|
||||||
|
)
|
||||||
|
|
||||||
|
override suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector) {
|
||||||
|
val propertiesBuildService = PropertiesBuildService.registerIfAbsent(project).get()
|
||||||
|
|
||||||
|
val usedDeprecatedProperties = deprecatedProperties.filter { propertiesBuildService.get(it, project) != null }
|
||||||
|
|
||||||
|
if (usedDeprecatedProperties.isNotEmpty()) {
|
||||||
|
collector.reportOncePerGradleBuild(
|
||||||
|
project,
|
||||||
|
KotlinToolingDiagnostics.DeprecatedGradleProperties(usedDeprecatedProperties)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -144,6 +144,7 @@ internal fun Project.registerKotlinPluginExtensions() {
|
|||||||
register(project, DuplicateSourceSetChecker)
|
register(project, DuplicateSourceSetChecker)
|
||||||
register(project, CInteropInputChecker)
|
register(project, CInteropInputChecker)
|
||||||
register(project, IncorrectNativeDependenciesChecker)
|
register(project, IncorrectNativeDependenciesChecker)
|
||||||
|
register(project, GradleDeprecatedPropertyChecker)
|
||||||
|
|
||||||
if (isMultiplatform) {
|
if (isMultiplatform) {
|
||||||
register(project, KotlinMultiplatformAndroidGradlePluginCompatibilityChecker)
|
register(project, KotlinMultiplatformAndroidGradlePluginCompatibilityChecker)
|
||||||
|
|||||||
Reference in New Issue
Block a user