From dd47962ad0b48390a215c2a7afe3f364a91cca18 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 9 Jul 2020 17:16:45 +0300 Subject: [PATCH] Extract current Kotlin version value into a separate class In order to selectively ignore it during classpath normalization, and do not recompile all the dependencies when just the version value changes. --- libraries/stdlib/src/kotlin/util/KotlinVersion.kt | 10 ++++++++-- prepare/build.version/build.gradle.kts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/kotlin/util/KotlinVersion.kt b/libraries/stdlib/src/kotlin/util/KotlinVersion.kt index 18106a6aa4a..2395a01198b 100644 --- a/libraries/stdlib/src/kotlin/util/KotlinVersion.kt +++ b/libraries/stdlib/src/kotlin/util/KotlinVersion.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 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. */ @@ -72,6 +72,12 @@ public class KotlinVersion(val major: Int, val minor: Int, val patch: Int) : Com * Returns the current version of the Kotlin standard library. */ @kotlin.jvm.JvmField - public val CURRENT: KotlinVersion = KotlinVersion(1, 4, 255) // value is written here automatically during build + public val CURRENT: KotlinVersion = KotlinVersionCurrentValue.get() } } + +// this class is ignored during classpath normalization when considering whether to recompile dependencies in Kotlin build +private object KotlinVersionCurrentValue { + @kotlin.jvm.JvmStatic + fun get(): KotlinVersion = KotlinVersion(1, 4, 255) // value is written here automatically during build +} \ No newline at end of file diff --git a/prepare/build.version/build.gradle.kts b/prepare/build.version/build.gradle.kts index ef413f9e24a..bb490328d05 100644 --- a/prepare/build.version/build.gradle.kts +++ b/prepare/build.version/build.gradle.kts @@ -35,7 +35,7 @@ val writeStdlibVersion by tasks.registering { inputs.property("version", kotlinVersion) outputs.file(versionFile) doLast { - replaceVersion(versionFile, """val CURRENT: KotlinVersion = KotlinVersion\((\d+, \d+, \d+)\)""") { + replaceVersion(versionFile, """fun get\(\): KotlinVersion = KotlinVersion\((\d+, \d+, \d+)\)""") { val (major, minor, _, optPatch) = Regex("""^(\d+)\.(\d+)(\.(\d+))?""").find(kotlinVersion)?.destructured ?: error("Cannot parse current version $kotlinVersion") val newVersion = "$major, $minor, ${optPatch.takeIf { it.isNotEmpty() } ?: "0" }" logger.lifecycle("Writing new standard library version components: $newVersion")