Skip to content

Commit 1fc1c6b

Browse files
committed
Fixed version formatting with ENV vars
1 parent 8040af8 commit 1fc1c6b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ configureProjectReport()
2020
configureNpm()
2121
configureApiValidation()
2222

23-
val kotlinVersionFull: String by extra
23+
val kotlinVersion = rootProject.libs.versions.kotlin.lang.get()
2424

2525
allprojects {
2626
group = "org.jetbrains.kotlinx"
2727
version = rootProject.libs.versions.kotlinx.rpc.get()
2828
}
2929

30-
println("kotlinx.rpc project version: $version, Kotlin version: $kotlinVersionFull")
30+
println("kotlinx.rpc project version: $version, Kotlin version: $kotlinVersion")
3131

3232
// If the prefix of the kPRC version is not Kotlin gradle plugin version – you have a problem :)
3333
// Probably some dependency brings kotlin with the later version.
3434
// To mitigate so, refer to `versions-root/kotlin-version-lookup.json`
3535
// and its usage in `gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts`
3636
val kotlinGPVersion = getKotlinPluginVersion()
37-
if (kotlinVersionFull != kotlinGPVersion) {
38-
error("KGP version mismatch. Project version: $kotlinVersionFull, KGP version: $kotlinGPVersion")
37+
if (kotlinVersion != kotlinGPVersion) {
38+
error("KGP version mismatch. Project version: $kotlinVersion, KGP version: $kotlinGPVersion")
3939
}

compiler-plugin/build.gradle.kts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import util.otherwise
6+
import util.whenForIde
7+
58
plugins {
69
alias(libs.plugins.conventions.gradle.doctor)
710
}
811

9-
val kotlinVersionFull: String by extra
1012
val rpcVersion: String = libs.versions.kotlinx.rpc.get()
13+
val kotlinCompilerVersion = libs.versions.kotlin.compiler.get()
14+
val kotlinLangVersion = libs.versions.kotlin.lang.get()
1115

1216
allprojects {
1317
group = "org.jetbrains.kotlinx"
14-
version = "$kotlinVersionFull-$rpcVersion"
18+
whenForIde {
19+
version = "$kotlinCompilerVersion-$rpcVersion"
20+
} otherwise {
21+
version = "$kotlinLangVersion-$rpcVersion"
22+
}
1523
}

gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,15 @@ fun VersionCatalogBuilder.resolveKotlinVersion(versionCatalog: Map<String, Strin
170170
// Uses LIBRARY_VERSION_ENV_VAR_NAME instead if present
171171
fun VersionCatalogBuilder.resolveLibraryVersion(versionCatalog: Map<String, String>) {
172172
val libraryCoreVersion: String = System.getenv(SettingsConventions.LIBRARY_VERSION_ENV_VAR_NAME)
173+
?.takeIf { it.isNotBlank() }
173174
?: versionCatalog[SettingsConventions.LIBRARY_CORE_VERSION_ALIAS]
174175
?: error("Expected to resolve '${SettingsConventions.LIBRARY_CORE_VERSION_ALIAS}' version")
175176

176177
val eapVersion: String = System.getenv(SettingsConventions.EAP_VERSION_ENV_VAR_NAME)
177178
?.let {
178-
when (it){
179-
"SNAPSHOT" -> "-$it"
179+
when {
180+
it.isBlank() -> ""
181+
it == "SNAPSHOT" -> "-$it"
180182
else -> "-eap-$it"
181183
}
182184
} ?: ""
@@ -203,19 +205,17 @@ dependencyResolutionManagement {
203205

204206
resolveLibraryVersion(versionCatalog)
205207

206-
// Other Kotlin-dependant versions
208+
// Other Kotlin-dependant versions
207209
val (lookupTable, latestKotlin) = loadLookupTable(rootDir, kotlinVersion)
208210

209211
val isLatestKotlin = latestKotlin == kotlinVersion
210212

211213
extra["kotlinVersion"] = kotlinVersion.kotlinVersionParsed()
212-
extra["kotlinVersionFull"] = kotlinVersion
213214
extra["isLatestKotlinVersion"] = isLatestKotlin
214215

215216
gradle.rootProject {
216217
allprojects {
217218
this.extra["kotlinVersion"] = kotlinVersion.kotlinVersionParsed()
218-
this.extra["kotlinVersionFull"] = kotlinVersion
219219
this.extra["isLatestKotlinVersion"] = isLatestKotlin
220220
}
221221
}

0 commit comments

Comments
 (0)