kotlinx.rpc 0.3.0 Help

Plugins

The kotlinx.rpc library offers plugins that simplify project configuration by automating repetitive tasks. Specifically, kotlinx.rpc provides two Gradle plugins:

org.jetbrains.kotlinx.rpc.platform

The org.jetbrains.kotlinx.rpc.platform plugin is particularly useful for versioning project dependencies. It adds BOM dependency to your project, that specifies proper versions for kotlinx.rpc dependencies. With this, you can skip specifying versions for each runtime dependency:

plugins { kotlin("jvm") version "2.0.10" id("org.jetbrains.kotlinx.rpc.platform") version "0.3.0" } dependencies { // versions are set automatically to 0.3.0 implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client") implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server") }

Using this plugin with version catalogs, your code can be rewritten like this:

# gradle / libs.versions.toml [versions] kotlinx-rpc-core = "0.3.0"; [libraries] kotlinx-rpc-client = { module = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-client" } [plugins] kotlinx-rpc-platform = { id = "org.jetbrains.kotlinx.rpc.platform"; version.ref = "kotlinx-rpc-core"; }
// build.gradle.kts plugins { alias(libs.plugins.kotlinx.rpc.platform) } dependencies { implementation(libs.kotlinx.rpc.client) }

org.jetbrains.kotlinx.rpc.plugin

The org.jetbrains.kotlinx.rpc.plugin plugin has the same BOM functionality as org.jetbrains.kotlinx.rpc.platform and it also sets up code generation configurations.

It is useful for multi-project setups where you define your RPC services in one set of subprojects and use in the other. In such a setup, you can add the plugin only to modules with service definitions to save time on building your project.

plugins { kotlin("jvm") version "2.0.10" id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0" }

Kotlin versions earlier than 2.0

If you are using a version of Kotlin prior to 2.0, you must also add the KSP (Kotlin Symbol Processing) Gradle plugin:

plugins { kotlin("jvm") version "1.9.25" id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0" id("com.google.devtools.ksp") version "1.9.25-1.0.20" }
Last modified: 19 August 2024