Skip to content

Commit

Permalink
Update the project structure to use a new versioning
Browse files Browse the repository at this point in the history
- Feature version for runtime modules
- Kotlin prefix version for compiler plugins
  • Loading branch information
Mr3zee committed Jun 4, 2024
1 parent 93b5b8a commit 7bae115
Show file tree
Hide file tree
Showing 42 changed files with 123 additions and 246 deletions.
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.serialization) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.rpc) apply false
alias(libs.plugins.kotlinx.rpc) apply false
alias(libs.plugins.atomicfu) apply false
alias(libs.plugins.detekt) apply false
alias(libs.plugins.kover.root.project) apply false
Expand Down Expand Up @@ -49,18 +49,18 @@ if (kotlinVersion >= "1.8.0") {

allprojects {
group = "org.jetbrains.kotlinx"
version = rootProject.libs.versions.rpc.full.get()
version = rootProject.libs.versions.kotlinx.rpc.get()
}

println("kotlinx.rpc project version: $version")
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 higher version.
// To mitigate so, please refer to `gradle/kotlin-version-lookup.json`
// and it's usage in `gradle-settings-conventions/src/main/kotlin/settings-conventions.settings.gradle.kts`
val kotlinGPVersion = getKotlinPluginVersion()
if (!version.toString().startsWith(kotlinGPVersion)) {
error("KGP version mismatch. Project version: $version, KGP version: $kotlinGPVersion")
if (kotlinVersion != kotlinGPVersion) {
error("KGP version mismatch. Project version: $kotlinVersion, KGP version: $kotlinGPVersion")
}

// necessary for CI js tests
Expand Down
8 changes: 4 additions & 4 deletions gradle-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ dependencies {
gradlePlugin {
plugins {
named("conventions-publishing") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}

plugins {
named("conventions-common") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}

plugins {
named("conventions-jvm") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}

plugins {
named("conventions-kmp") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
gradlePlugin {
plugins {
named("compiler-specific-module") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ fun Project.lazyImplementation(notation: Any) {
val root = project

subprojects {
version = "$kotlinVersion-$version"
println("Compiler-specific module $name, version: $version")

when {
name == coreProjectName -> {
lazyImplementation(project(CSM.SERVICE_LOADER_MODULE))
Expand Down
29 changes: 0 additions & 29 deletions gradle-conventions/gradle-publish-stub/build.gradle.kts

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion gradle-conventions/gradle-publish/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gradlePlugin {
plugins {
named("conventions-gradle-publish") {
id = "conventions-gradle-publish"
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
2 changes: 1 addition & 1 deletion gradle-conventions/kover-stub/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gradlePlugin {
plugins {
named("kover-root-project") {
id = "kover-root-project"
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
2 changes: 1 addition & 1 deletion gradle-conventions/kover/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gradlePlugin {
plugins {
named("kover-root-project") {
id = "kover-root-project"
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
9 changes: 2 additions & 7 deletions gradle-conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ plugins {

include(":compiler-specific-module")

val kotlinVersion: String by extra
val isLatestKotlinVersion: Boolean by extra

if (kotlinVersion >= "1.8.0") {
include(":kover")
} else {
include(":kover-stub")
}

if (isLatestKotlinVersion) {
include(":kover")
include(":gradle-publish")
} else {
include(":kover-stub")
include(":gradle-publish-stub")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import io.gitlab.arturbosch.detekt.Detekt
import util.libs

plugins {
id("io.gitlab.arturbosch.detekt")
Expand All @@ -17,8 +16,6 @@ val globalDetektDir = "$globalRootDir/detekt"

// https://detekt.dev/docs/gettingstarted/gradle#options-for-detekt-configuration-closure
detekt {
toolVersion = libs.versions.detekt.analyzer.get()

buildUponDefaultConfig = false

// TC will fail only on Detekt codestyle configuration
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {

subprojects {
group = "org.jetbrains.kotlinx"
version = rootProject.libs.versions.rpc.core.get()
version = rootProject.libs.versions.kotlinx.rpc.get()

fun alias(notation: Provider<PluginDependency>): String {
return notation.get().pluginId
Expand Down
2 changes: 1 addition & 1 deletion gradle-settings-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ configurations.configureEach {
gradlePlugin {
plugins {
named("settings-conventions") {
version = libs.versions.rpc.core.get()
version = libs.versions.kotlinx.rpc.get()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ object SettingsConventions {
const val EAP_VERSION_ENV_VAR_NAME = "EAP_VERSION"

const val KSP_VERSION_ALIAS = "ksp"
const val LIBRARY_CORE_VERSION_ALIAS = "rpc-core"
const val LIBRARY_FULL_VERSION_ALIAS = "rpc-full"
const val LIBRARY_CORE_VERSION_ALIAS = "kotlinx-rpc"
const val KOTLIN_VERSION_ALIAS = "kotlin-lang"

const val VERSIONS_SECTION_NAME = "[versions]"
Expand Down Expand Up @@ -160,17 +159,14 @@ fun VersionCatalogBuilder.resolveKotlinVersion(versionCatalog: Map<String, Strin

// Resolves core kotlinx.rpc version (without Kotlin version prefix) from Versions Catalog.
// Updates it with EAP_VERSION suffix of present.
// Sets kotlinx.rpc full version (with Kotlin version prefix) into Version Catalog.
fun VersionCatalogBuilder.resolveLibraryVersion(versionCatalog: Map<String, String>, kotlinVersion: String) {
fun VersionCatalogBuilder.resolveLibraryVersion(versionCatalog: Map<String, String>) {
val eapVersion: String = System.getenv(SettingsConventions.EAP_VERSION_ENV_VAR_NAME)
?.let { "-eap-$it" } ?: ""
val libraryCatalogVersion = versionCatalog[SettingsConventions.LIBRARY_CORE_VERSION_ALIAS]
?: error("Expected to resolve '${SettingsConventions.LIBRARY_CORE_VERSION_ALIAS}' version")
val libraryCoreVersion = libraryCatalogVersion + eapVersion
val libraryFullVersion = "$kotlinVersion-$libraryCoreVersion"

version(SettingsConventions.LIBRARY_CORE_VERSION_ALIAS, libraryCoreVersion)
version(SettingsConventions.LIBRARY_FULL_VERSION_ALIAS, libraryFullVersion)
}

dependencyResolutionManagement {
Expand All @@ -190,7 +186,7 @@ dependencyResolutionManagement {

val kotlinVersion = resolveKotlinVersion(versionCatalog)

resolveLibraryVersion(versionCatalog, kotlinVersion)
resolveLibraryVersion(versionCatalog)

// Other Kotlin-dependant versions
val (lookupTable, latestKotlin) = loadLookupTable(rootDir, kotlinVersion)
Expand Down
36 changes: 18 additions & 18 deletions gradle/kotlin-versions-lookup.csv
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Kotlin,ksp,atomicfu,serialization,coroutines,ktor,detekt-gradle-plugin,kotlin-logging,gradle-kotlin-dsl,binary-compatibility-validator,kover
1.9.24,1.0.20,0.22.0,1.6.1,1.8.1,2.3.11,1.23.6,6.0.9,4.1.0,0.14.0,0.8.0
1.9.23,1.0.19,0.22.0,1.6.1,1.8.1,2.3.11,1.23.6,6.0.9,4.1.0,0.14.0,0.8.0
1.9.22,1.0.17,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.22,4.1.0
1.9.21,4.1.0
1.9.20,4.1.0
1.9.10,4.1.0
1.9.0,4.1.0
1.8.22,4.0.6
1.8.21,4.0.6
1.8.20,4.0.6
1.8.10,4.0.6
1.8.0,4.0.0
1.7.22,2.3.3
1.7.21,2.3.3
1.7.20,2.3.3
1.7.10,2.3.3
1.7.0,2.3.3
48 changes: 22 additions & 26 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
[versions]
# kotlin
kotlin-lang = "1.9.24"
rpc-core = "0.1.1-SNAPSHOT" # version for plugins and suffix for rpc-full
kotlinx-rpc = "0.1.1-SNAPSHOT" # version for plugins and suffix for rpc-full

# kotlin-dependent versions, will be replaced with the actual versions by a settings-conventions plugin
# from 'kotlin-versions-lookup.json' lookup table
rpc-full = "<stub>" # rpc-core prefixed by kotlin-lang
ksp = "<stub>"
atomicfu = "<stub>"
serialization = "<stub>"
coroutines = "<stub>"
ktor = "<stub>"
detekt-gradle-plugin = "<stub>"
kotlin-logging = "<stub>"
gradle-kotlin-dsl = "<stub>"
binary-compatibility-validator = "<stub>"
kover = "<stub>"

# other
detekt-analyzer = "1.23.6" # actual version of the tool, can be different from gradle plugin
ksp = "1.9.24-1.0.20"
atomicfu = "0.22.0"
serialization = "1.6.1"
coroutines = "1.8.1"
ktor = "2.3.11"
detekt = "1.23.6"
kotlin-logging = "6.0.9"
binary-compatibility-validator = "0.14.0"
kover = "0.8.0"
slf4j = "2.0.13"
logback = "1.3.14"
gradle-plugin-publish = "1.2.1"

# stub versions - relpaced based on kotlin
gradle-kotlin-dsl = "<stub>"

[libraries]
# kotlin
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-lang" }
Expand Down Expand Up @@ -63,7 +59,7 @@ kotlin-logging = { module = "io.github.oshai:kotlin-logging", version.ref = "kot
kotlin-logging-legacy = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt-gradle-plugin" }
detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
kover-gradle-plugin = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }

[plugins]
Expand All @@ -72,20 +68,20 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-lang" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-lang" }

ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt-gradle-plugin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
atomicfu = { id = "kotlinx-atomicfu", version.ref = "atomicfu" }
gradle-kotlin-dsl = { id = "org.gradle.kotlin.kotlin-dsl", version.ref = "gradle-kotlin-dsl" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }

# gradle-conventions project
conventions-common = { id = "conventions-common", version.ref = "rpc-core" }
conventions-jvm = { id = "conventions-jvm", version.ref = "rpc-core" }
conventions-kmp = { id = "conventions-kmp", version.ref = "rpc-core" }
conventions-gradle-publish = { id = "conventions-gradle-publish", version.ref = "rpc-core" }
compiler-specific-module = { id = "compiler-specific-module", version.ref = "rpc-core" }
kover-root-project = { id = "kover-root-project", version.ref = "rpc-core" }
conventions-common = { id = "conventions-common", version.ref = "kotlinx-rpc" }
conventions-jvm = { id = "conventions-jvm", version.ref = "kotlinx-rpc" }
conventions-kmp = { id = "conventions-kmp", version.ref = "kotlinx-rpc" }
conventions-gradle-publish = { id = "conventions-gradle-publish", version.ref = "kotlinx-rpc" }
compiler-specific-module = { id = "compiler-specific-module", version.ref = "kotlinx-rpc" }
kover-root-project = { id = "kover-root-project", version.ref = "kotlinx-rpc" }

# gradle-plugin project
rpc = { id = "org.jetbrains.kotlinx.rpc.plugin", version.ref = "rpc-core" }
kotlinx-rpc = { id = "org.jetbrains.kotlinx.rpc.plugin", version.ref = "kotlinx-rpc" }
4 changes: 2 additions & 2 deletions runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
alias(libs.plugins.conventions.kmp)
alias(libs.plugins.serialization)
alias(libs.plugins.ksp)
alias(libs.plugins.rpc)
alias(libs.plugins.kotlinx.rpc)
alias(libs.plugins.atomicfu)
}

Expand Down Expand Up @@ -62,7 +62,7 @@ kotlin {
}

tasks.withType<KotlinJvmTest> {
environment("LIBRARY_VERSION", libs.versions.rpc.core.get())
environment("LIBRARY_VERSION", libs.versions.kotlinx.rpc.get())
}

val resourcesPath = projectDir.resolve("src/jvmTest/resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlinx.rpc.client.internal.RPCClientConnector
import kotlinx.rpc.client.internal.RPCFlow
import kotlinx.rpc.internal.*
import kotlinx.rpc.internal.logging.CommonLogger
import kotlinx.rpc.internal.logging.initialized
import kotlinx.rpc.internal.logging.impl.initialized
import kotlinx.rpc.internal.transport.*
import kotlinx.serialization.BinaryFormat
import kotlinx.serialization.SerialFormat
Expand Down
13 changes: 12 additions & 1 deletion runtime/runtime-logging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@

plugins {
alias(libs.plugins.conventions.kmp)
alias(libs.plugins.compiler.specific.module)
}

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlin.logging)
implementation(project(":kotlinx-rpc-runtime:kotlinx-rpc-runtime-api"))
implementation(project(":kotlinx-rpc-utils:kotlinx-rpc-utils-service-loader"))
}
}
}
}
Loading

0 comments on commit 7bae115

Please sign in to comment.