[Gradle] Cleanup: remove SingleWarningPerBuild API

Instead, newer infrastructure for diagnostics should be used (see
'KotlinToolingDiagnosticsCollector')
This commit is contained in:
Dmitry Savvinov
2023-03-27 16:46:15 +02:00
parent 8a5433734b
commit e74e6759ed
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.gradle.utils
import org.gradle.api.Project
import org.gradle.api.logging.Logger
import java.util.*
/**
@@ -50,40 +49,3 @@ internal object SingleActionPerBuild : SingleAction() {
internal object SingleActionPerProject : SingleAction() {
override fun selectKey(project: Project) = project
}
/**
* Object that allows to display warning once per build
*
* Warning: if KGP is loaded multiple times by different classloaders, warnings with the same id may be shown more than once
*/
internal object SingleWarningPerBuild {
private const val ACTION_ID_SHOW_WARNING = "show-warning:"
/**
* Prints a warning with [warningText] using logger of [project]
*
* Warning: if KGP is loaded multiple times by different classloaders, warnings with the same id may be shown more than once
*/
fun show(project: Project, warningText: String) = show(project, project.logger, warningText)
/**
* Prints a warning with [warningText] using [logger]
*
* Warning: if KGP is loaded multiple times by different classloaders, warnings with the same id may be shown more than once
*/
fun show(project: Project, logger: Logger, warningText: String) =
SingleActionPerBuild.run(project, ACTION_ID_SHOW_WARNING + warningText) {
logger.warn(warningText)
}
/**
* Prints a deprecation warning for [target] of type [type] using logger of [project].
* If there's a replacement for it, you could specify [replacement]
*
* Warning: if KGP is loaded multiple times by different classloaders, warnings with the same id may be shown more than once
*/
fun deprecation(project: Project, type: String, target: String, replacement: String? = null) {
val replacementMessage = replacement?.let { " Please, use '$replacement' instead." } ?: ""
show(project, "Warning: $type '$target' is deprecated and will be removed in next major releases.$replacementMessage\n")
}
}