Skip to content

Fixed version formatting with ENV vars #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
12 changes: 10 additions & 2 deletions compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ fun VersionCatalogBuilder.resolveKotlinVersion(versionCatalog: Map<String, Strin
// Uses LIBRARY_VERSION_ENV_VAR_NAME instead if present
fun VersionCatalogBuilder.resolveLibraryVersion(versionCatalog: Map<String, String>) {
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"
}
} ?: ""
Expand All @@ -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
}
}
Expand Down