diff --git a/build.gradle.kts b/build.gradle.kts index 316944514..cbfdc3a4f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,20 +20,20 @@ configureProjectReport() configureNpm() configureApiValidation() -val kotlinVersionFull: String by extra +val kotlinVersion = rootProject.libs.versions.kotlin.lang.get() allprojects { group = "org.jetbrains.kotlinx" version = rootProject.libs.versions.kotlinx.rpc.get() } -println("kotlinx.rpc project version: $version, Kotlin version: $kotlinVersionFull") +println("kotlinx.rpc project version: $version, Kotlin version: $kotlinVersion") // If the prefix of the kPRC version is not Kotlin gradle plugin version – you have a problem :) // Probably some dependency brings kotlin with the later version. // To mitigate so, refer to `versions-root/kotlin-version-lookup.json` // and its usage in `gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts` val kotlinGPVersion = getKotlinPluginVersion() -if (kotlinVersionFull != kotlinGPVersion) { - error("KGP version mismatch. Project version: $kotlinVersionFull, KGP version: $kotlinGPVersion") +if (kotlinVersion != kotlinGPVersion) { + error("KGP version mismatch. Project version: $kotlinVersion, KGP version: $kotlinGPVersion") } diff --git a/compiler-plugin/build.gradle.kts b/compiler-plugin/build.gradle.kts index 195638415..cc9fe7e33 100644 --- a/compiler-plugin/build.gradle.kts +++ b/compiler-plugin/build.gradle.kts @@ -2,14 +2,22 @@ * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ +import util.otherwise +import util.whenForIde + plugins { alias(libs.plugins.conventions.gradle.doctor) } -val kotlinVersionFull: String by extra val rpcVersion: String = libs.versions.kotlinx.rpc.get() +val kotlinCompilerVersion = libs.versions.kotlin.compiler.get() +val kotlinLangVersion = libs.versions.kotlin.lang.get() allprojects { group = "org.jetbrains.kotlinx" - version = "$kotlinVersionFull-$rpcVersion" + whenForIde { + version = "$kotlinCompilerVersion-$rpcVersion" + } otherwise { + version = "$kotlinLangVersion-$rpcVersion" + } } diff --git a/gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts b/gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts index ec07aa03b..71932571a 100644 --- a/gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts +++ b/gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts @@ -170,13 +170,15 @@ fun VersionCatalogBuilder.resolveKotlinVersion(versionCatalog: Map) { val libraryCoreVersion: String = System.getenv(SettingsConventions.LIBRARY_VERSION_ENV_VAR_NAME) + ?.takeIf { it.isNotBlank() } ?: versionCatalog[SettingsConventions.LIBRARY_CORE_VERSION_ALIAS] ?: error("Expected to resolve '${SettingsConventions.LIBRARY_CORE_VERSION_ALIAS}' version") val eapVersion: String = System.getenv(SettingsConventions.EAP_VERSION_ENV_VAR_NAME) ?.let { - when (it){ - "SNAPSHOT" -> "-$it" + when { + it.isBlank() -> "" + it == "SNAPSHOT" -> "-$it" else -> "-eap-$it" } } ?: "" @@ -203,19 +205,17 @@ dependencyResolutionManagement { resolveLibraryVersion(versionCatalog) - // Other Kotlin-dependant versions + // Other Kotlin-dependant versions val (lookupTable, latestKotlin) = loadLookupTable(rootDir, kotlinVersion) val isLatestKotlin = latestKotlin == kotlinVersion extra["kotlinVersion"] = kotlinVersion.kotlinVersionParsed() - extra["kotlinVersionFull"] = kotlinVersion extra["isLatestKotlinVersion"] = isLatestKotlin gradle.rootProject { allprojects { this.extra["kotlinVersion"] = kotlinVersion.kotlinVersionParsed() - this.extra["kotlinVersionFull"] = kotlinVersion this.extra["isLatestKotlinVersion"] = isLatestKotlin } }