Restore removed 'kotlinPluginVersion' property.

And marked it as '@Deprecated'.

^KT-47317 Fixed
This commit is contained in:
Yahor Berdnikau
2021-06-17 17:30:58 +02:00
parent b68c00e0e9
commit 030697d430
@@ -54,6 +54,15 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
private val log = Logging.getLogger(this.javaClass)
@Deprecated(
message = "Scheduled to be removed in 1.7 release",
replaceWith = ReplaceWith(
"project.getKotlinPluginVersion()",
"org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion"
)
)
val kotlinPluginVersion by lazy { loadKotlinVersionFromResource(log) }
open val projectExtensionClass: KClass<out KotlinTopLevelExtension> get() = KotlinProjectExtension::class
internal open fun kotlinSourceSetFactory(project: Project): NamedDomainObjectFactory<KotlinSourceSet> =
@@ -252,6 +261,20 @@ open class KotlinPm20PluginWrapper @Inject constructor(private val objectFactory
get() = KotlinPm20ProjectExtension::class
}
@Deprecated(
message = "Scheduled to be removed in 1.7 release",
replaceWith = ReplaceWith(
"project.getKotlinPluginVersion()",
"org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion"
)
)
fun Plugin<*>.loadKotlinVersionFromResource(log: Logger): String {
log.kotlinDebug("Loading version information")
val projectVersion = loadPropertyFromResources("project.properties", "project.version")
log.kotlinDebug("Found project version [$projectVersion]")
return projectVersion
}
fun Project.getKotlinPluginVersion(): String {
if (!kotlinPluginVersionFromResources.isInitialized()) {
project.logger.kotlinDebug("Loading version information")
@@ -265,4 +288,4 @@ private fun loadKotlinPluginVersionFromResourcesOf(any: Any) =
private val kotlinPluginVersionFromResources = lazy {
loadKotlinPluginVersionFromResourcesOf(object {})
}
}