From 7f4289af8ae3bb4cf8802e32780069af0124e004 Mon Sep 17 00:00:00 2001
From: Alexander Sysoev
Date: Wed, 30 Oct 2024 11:30:21 +0100
Subject: [PATCH] Remove configurations and code for Kotlin versions prior to
2.0
---
README.md | 7 +-
build.gradle.kts | 7 +-
.../extension/RPCDeclarationScanner.kt | 10 +-
.../rpc/codegen/extension/RPCStubGenerator.kt | 27 +--
.../rpc/codegen/VersionSpecificApiImpl.kt | 59 ------
.../rpc/codegen/VersionSpecificApiImpl.kt | 73 -------
.../rpc/codegen/VersionSpecificApiImpl.kt | 77 -------
.../rpc/codegen/VersionSpecificApiImpl.kt | 79 -------
...otlin.compiler.plugin.CommandLineProcessor | 5 -
....kotlin.compiler.plugin.ComponentRegistrar | 5 -
.../kotlinx/rpc/codegen/RPCCompilerPlugin.kt | 33 ---
.../kotlinx/rpc/codegen/RPCCompilerPlugin.kt | 29 ---
.../kotlinx/rpc/codegen/RPCCompilerPlugin.kt | 31 ---
.../core/kotlinx/rpc/codegen/common/Names.kt | 3 -
.../compiler-plugin-k2/build.gradle.kts | 5 +-
.../src/main/v_1/kotlinx/rpc/codegen/Stub.kt | 5 -
.../rpc/internal/WithRPCStubObject.jvm.kt | 12 +-
docs/Multiple-Kotlin-Versions-Support.md | 1 -
docs/pages/kotlinx-rpc/topics/versions.topic | 7 +-
.../settings.gradle.kts | 6 +-
.../settings-conventions.settings.gradle.kts | 15 +-
.../src/main/kotlin/util/KotlinVersion.kt | 1 +
.../src/main/kotlin/util/TargetUtils.kt | 18 --
.../src/main/kotlin/util/atomicfu.kt | 6 +-
.../conventions-kotlin-version.gradle.kts | 4 +-
.../compiler-specific-module.gradle.kts | 20 --
.../kotlin/conventions-publishing.gradle.kts | 18 +-
.../main/pre_1_9_20/util/contextReceivers.kt | 17 --
.../src/main/pre_1_9_20/util/wasm.kt | 9 -
.../main/pre_1_9_25/util/contextReceivers.kt | 23 --
.../src/main/pre_1_9_25/util/wasm.kt | 9 -
gradle-plugin/build.gradle.kts | 13 --
.../kotlin/kotlinx/rpc/RPCGradlePlugin.kt | 78 -------
.../kotlin/kotlinx/rpc/RPCPlatformPlugin.kt | 32 ---
.../main/kotlin/kotlinx/rpc/RPCPluginConst.kt | 9 +-
gradle.properties | 5 -
gradle/wrapper/gradle-wrapper.properties | 2 +-
.../client/internal/RPCClientConnector.kt | 6 +-
krpc/krpc-core/api/krpc-core.api | 2 +-
.../kotlin/kotlinx/rpc/krpc/StreamScope.kt | 2 -
.../rpc/krpc/internal/CancellationType.kt | 5 +-
.../kotlinx/rpc/krpc/internal/RPCConnector.kt | 10 +-
.../kotlinx/rpc/krpc/internal/RPCPlugin.kt | 3 +-
.../kotlinx/rpc/krpc/internal/RPCPluginKey.kt | 3 +-
.../server/internal/RPCServerConnector.kt | 6 +-
.../kotlinx/rpc/krpc/test/ProtocolTest.kt | 4 +-
.../krpc/test/api/WireSamplingTestScope.kt | 7 +-
ksp-plugin/build.gradle.kts | 25 ---
ksp-plugin/gradle.properties | 1 -
ksp-plugin/settings.gradle.kts | 19 --
.../rpc/codegen/ACodeGenerationException.kt | 88 --------
.../kotlin/kotlinx/rpc/codegen/CodeWriter.kt | 30 ---
.../rpc/codegen/RPCClientServiceGenerator.kt | 120 -----------
.../rpc/codegen/RPCServiceDeclaration.kt | 65 ------
.../kotlinx/rpc/codegen/RPCSymbolProcessor.kt | 198 ------------------
.../rpc/codegen/RPCSymbolProcessorContext.kt | 27 ---
.../rpc/codegen/RPCSymbolProcessorProvider.kt | 15 --
...ols.ksp.processing.SymbolProcessorProvider | 5 -
publishLocal.sh | 6 -
settings.gradle.kts | 11 -
.../rpc/internal/utils/AutoCloseable.kt | 48 -----
.../rpc/internal/utils/hex/HexBytes.kt | 49 +----
versions-root/kotlin-versions-lookup.csv | 28 +--
versions-root/libs.versions.toml | 9 +-
.../targets-since-kotlin-lookup.json | 28 +--
65 files changed, 79 insertions(+), 1501 deletions(-)
delete mode 100644 compiler-plugin/compiler-plugin-backend/src/main/v_1_7/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
delete mode 100644 compiler-plugin/compiler-plugin-backend/src/main/v_1_7_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
delete mode 100644 compiler-plugin/compiler-plugin-backend/src/main/v_1_8/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
delete mode 100644 compiler-plugin/compiler-plugin-backend/src/main/v_1_9/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
delete mode 100644 compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
delete mode 100644 compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
delete mode 100644 compiler-plugin/compiler-plugin-cli/src/main/v_1/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
delete mode 100644 compiler-plugin/compiler-plugin-cli/src/main/v_1_7/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
delete mode 100644 compiler-plugin/compiler-plugin-cli/src/main/v_1_7_2/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
delete mode 100644 compiler-plugin/compiler-plugin-k2/src/main/v_1/kotlinx/rpc/codegen/Stub.kt
delete mode 100644 gradle-conventions/src/main/pre_1_9_20/util/contextReceivers.kt
delete mode 100644 gradle-conventions/src/main/pre_1_9_20/util/wasm.kt
delete mode 100644 gradle-conventions/src/main/pre_1_9_25/util/contextReceivers.kt
delete mode 100644 gradle-conventions/src/main/pre_1_9_25/util/wasm.kt
delete mode 100644 gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPlatformPlugin.kt
delete mode 100644 ksp-plugin/build.gradle.kts
delete mode 120000 ksp-plugin/gradle.properties
delete mode 100644 ksp-plugin/settings.gradle.kts
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/ACodeGenerationException.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/CodeWriter.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCClientServiceGenerator.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCServiceDeclaration.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessor.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorContext.kt
delete mode 100644 ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorProvider.kt
delete mode 100644 ksp-plugin/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
delete mode 100644 utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/AutoCloseable.kt
diff --git a/README.md b/README.md
index fd28c894..59337624 100644
--- a/README.md
+++ b/README.md
@@ -157,11 +157,8 @@ Integrations in progress:
- Integration with [gRPC](https://grpc.io/) (in prototype)
## Kotlin compatibility
-We support all stable Kotlin versions starting from 1.7.0:
-- 1.7.0, 1.7.10, 1.7.20, 1.7.21, 1.7.22
-- 1.8.0, 1.8.10, 1.8.20, 1.8.21, 1.8.22
-- 1.9.0, 1.9.10, 1.9.20, 1.9.21, 1.9.22, 1.9.23, 1.9.24, 1.9.25
-- 2.0.0, 2.0.10
+We support all stable Kotlin versions starting from 2.0.0:
+- 2.0.0, 2.0.10, 2.0.20, 2.0.21
To simplify project configuration, our Gradle plugin sets a proper library version automatically using BOM,
based on the project's Kotlin version:
diff --git a/build.gradle.kts b/build.gradle.kts
index 4404d2c5..e4edbc46 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -11,12 +11,7 @@ plugins {
alias(libs.plugins.conventions.kover)
alias(libs.plugins.conventions.gradle.doctor)
alias(libs.plugins.binary.compatibility.validator)
-
- if (libs.versions.atomicfu.get() >= "0.24.0") {
- alias(libs.plugins.atomicfu.new)
- } else {
- alias(libs.plugins.atomicfu.old)
- }
+ alias(libs.plugins.atomicfu)
}
// useful for dependencies introspection
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCDeclarationScanner.kt b/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCDeclarationScanner.kt
index b67314b4..241b01a6 100644
--- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCDeclarationScanner.kt
+++ b/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCDeclarationScanner.kt
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.util.dumpKotlinLike
-import org.jetbrains.kotlin.ir.util.packageFqName
/**
* This class scans user declared RPC service
@@ -73,15 +72,8 @@ internal object RPCDeclarationScanner {
}
}
- val packageName = service.packageFqName?.asString()
- ?: error("Expected package name of the ${service.name.asString()}")
-
val stubClassNotNull = stubClass
- // only for KSP generation
- ?: ctx.getIrClassSymbol(
- packageName = packageName,
- name = "${service.name.asString()}${RpcNames.SERVICE_STUB_NAME_KSP.asString()}"
- ).owner
+ ?: error("Expected generated stub class to be present in ${service.name.asString()}. FIR failed to do so.")
return ServiceDeclaration(
service = service,
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCStubGenerator.kt b/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCStubGenerator.kt
index a70483aa..00ad159e 100644
--- a/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCStubGenerator.kt
+++ b/compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RPCStubGenerator.kt
@@ -7,7 +7,6 @@ package kotlinx.rpc.codegen.extension
import kotlinx.rpc.codegen.VersionSpecificApi
import kotlinx.rpc.codegen.VersionSpecificApiImpl.copyToVS
import kotlinx.rpc.codegen.common.rpcMethodClassName
-import kotlinx.rpc.codegen.common.rpcMethodClassNameKsp
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
import org.jetbrains.kotlin.backend.jvm.functionByName
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -156,7 +155,7 @@ internal class RPCStubGenerator(
propertyName: String,
propertyType: IrType,
valueParameter: IrValueParameter,
- propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE
+ propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE,
): IrProperty {
return addConstructorProperty(Name.identifier(propertyName), propertyType, valueParameter, propertyVisibility)
}
@@ -165,7 +164,7 @@ internal class RPCStubGenerator(
propertyName: Name,
propertyType: IrType,
valueParameter: IrValueParameter,
- propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE
+ propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE,
): IrProperty {
return addProperty {
name = propertyName
@@ -537,8 +536,7 @@ internal class RPCStubGenerator(
val isMethodObject = method.arguments.isEmpty()
val methodClassName = method.function.name.rpcMethodClassName
- val methodClassNameKsp = method.function.name.rpcMethodClassNameKsp
- val methodClass: IrClass = initiateAndGetMethodClass(methodClassName, methodClassNameKsp, method)
+ val methodClass: IrClass = initiateAndGetMethodClass(methodClassName, method)
addFunction {
name = method.function.name
@@ -652,17 +650,12 @@ internal class RPCStubGenerator(
* }
* ```
*/
- private fun IrClass.initiateAndGetMethodClass(
- methodClassName: Name,
- methodClassNameKsp: Name,
- method: ServiceDeclaration.Method
- ): IrClass {
- val methodClass = findDeclaration {
- it.name == methodClassName || it.name == methodClassNameKsp
- } ?: error(
- "Expected $methodClassName or $methodClassNameKsp class to be present in stub class " +
- "${declaration.service.name}${declaration.stubClass.name}"
- )
+ private fun IrClass.initiateAndGetMethodClass(methodClassName: Name, method: ServiceDeclaration.Method): IrClass {
+ val methodClass = findDeclaration { it.name == methodClassName }
+ ?: error(
+ "Expected $methodClassName class to be present in stub class " +
+ "${declaration.service.name}${declaration.stubClass.name}"
+ )
methodClasses.add(methodClass)
@@ -764,7 +757,7 @@ internal class RPCStubGenerator(
functionThisReceiver: IrValueParameter,
isMethodObject: Boolean,
methodClass: IrClass,
- arguments: List
+ arguments: List,
): IrCall {
val call = irCall(
callee = ctx.functions.rpcClientCall.symbol,
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/v_1_7/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/v_1_7/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
deleted file mode 100644
index 5ace7d7c..00000000
--- a/compiler-plugin/compiler-plugin-backend/src/main/v_1_7/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
-import org.jetbrains.kotlin.backend.common.ir.copyTo
-import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder
-import org.jetbrains.kotlin.ir.builders.declarations.addExtensionReceiver
-import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.types.IrType
-import org.jetbrains.kotlin.name.FqName
-import org.jetbrains.kotlin.platform.TargetPlatform
-import org.jetbrains.kotlin.platform.js.isJs
-
-object VersionSpecificApiImpl : VersionSpecificApi {
- override fun isJs(platform: TargetPlatform?): Boolean {
- return platform.isJs()
- }
-
- override fun isWasm(platform: TargetPlatform?): Boolean = false
-
- override var IrFieldBuilder.isFinalVS: Boolean
- get() = undefinedAPI()
- set(_) {}
-
- override var IrCall.originVS: IrStatementOrigin?
- get() = origin
- set(_) {}
-
- override var IrConstructor.isPrimaryVS: Boolean
- get() = isPrimary
- set(_) {}
-
- override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? {
- return context.referenceClass(FqName("$packageName.$name"))
- }
-
- override fun referenceFunctions(
- context: IrPluginContext,
- packageName: String,
- name: String
- ): Collection {
- return context.referenceFunctions(FqName("$packageName.$name"))
- }
-
- override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter {
- return copyTo(irFunction, origin)
- }
-
- override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter {
- return addExtensionReceiver(type, origin)
- }
-}
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/v_1_7_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/v_1_7_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
deleted file mode 100644
index b4802b7f..00000000
--- a/compiler-plugin/compiler-plugin-backend/src/main/v_1_7_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
-import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver
-import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder
-import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.types.IrType
-import org.jetbrains.kotlin.ir.util.copyTo
-import org.jetbrains.kotlin.name.CallableId
-import org.jetbrains.kotlin.name.ClassId
-import org.jetbrains.kotlin.name.FqName
-import org.jetbrains.kotlin.name.Name
-import org.jetbrains.kotlin.platform.TargetPlatform
-import org.jetbrains.kotlin.platform.js.isJs
-
-object VersionSpecificApiImpl : VersionSpecificApi {
- override fun isJs(platform: TargetPlatform?): Boolean {
- return platform.isJs()
- }
-
- override fun isWasm(platform: TargetPlatform?): Boolean = false
-
- override var IrFieldBuilder.isFinalVS: Boolean
- get() = undefinedAPI()
- set(_) {}
-
- override var IrCall.originVS: IrStatementOrigin?
- get() = origin
- set(_) {}
-
- override var IrConstructor.isPrimaryVS: Boolean
- get() = isPrimary
- set(_) {}
-
- override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? {
- return context.referenceClass(
- ClassId(
- FqName(packageName),
- FqName(name),
- false
- )
- )
- }
-
- override fun referenceFunctions(
- context: IrPluginContext,
- packageName: String,
- name: String
- ): Collection {
- return context.referenceFunctions(
- CallableId(
- FqName(packageName),
- Name.identifier(name),
- )
- )
- }
-
- override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter {
- return copyTo(irFunction, origin)
- }
-
- override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter {
- return addExtensionReceiver(type, origin)
- }
-}
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/v_1_8/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/v_1_8/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
deleted file mode 100644
index 5eff1005..00000000
--- a/compiler-plugin/compiler-plugin-backend/src/main/v_1_8/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
-import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver
-import org.jetbrains.kotlin.descriptors.Modality
-import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder
-import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.types.IrType
-import org.jetbrains.kotlin.ir.util.copyTo
-import org.jetbrains.kotlin.name.CallableId
-import org.jetbrains.kotlin.name.ClassId
-import org.jetbrains.kotlin.name.FqName
-import org.jetbrains.kotlin.name.Name
-import org.jetbrains.kotlin.platform.TargetPlatform
-import org.jetbrains.kotlin.platform.js.isJs
-
-object VersionSpecificApiImpl : VersionSpecificApi {
- override fun isJs(platform: TargetPlatform?): Boolean {
- return platform.isJs()
- }
-
- override fun isWasm(platform: TargetPlatform?): Boolean = false
-
- override var IrFieldBuilder.isFinalVS: Boolean
- get() = undefinedAPI()
- set(_) {}
-
- override var IrCall.originVS: IrStatementOrigin?
- get() = origin
- set(_) {}
-
- override var IrConstructor.isPrimaryVS: Boolean
- get() = isPrimary
- set(_) {}
-
- override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? {
- return context.referenceClass(
- ClassId(
- FqName(packageName),
- FqName(name),
- false
- )
- )
- }
-
- override fun referenceFunctions(
- context: IrPluginContext,
- packageName: String,
- name: String
- ): Collection {
- return context.referenceFunctions(
- CallableId(
- FqName(packageName),
- Name.identifier(name),
- )
- )
- }
-
- override fun IrValueParameter.copyToVS(
- irFunction: IrFunction,
- origin: IrDeclarationOrigin,
- ): IrValueParameter {
- return copyTo(irFunction)
- }
-
- override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter {
- return addExtensionReceiver(type, origin)
- }
-}
diff --git a/compiler-plugin/compiler-plugin-backend/src/main/v_1_9/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/v_1_9/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
deleted file mode 100644
index aff11318..00000000
--- a/compiler-plugin/compiler-plugin-backend/src/main/v_1_9/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
-import org.jetbrains.kotlin.backend.common.ir.addExtensionReceiver
-import org.jetbrains.kotlin.descriptors.Modality
-import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder
-import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.types.IrType
-import org.jetbrains.kotlin.ir.types.impl.IrErrorClassImpl.modality
-import org.jetbrains.kotlin.ir.util.copyTo
-import org.jetbrains.kotlin.name.CallableId
-import org.jetbrains.kotlin.name.ClassId
-import org.jetbrains.kotlin.name.FqName
-import org.jetbrains.kotlin.name.Name
-import org.jetbrains.kotlin.platform.TargetPlatform
-import org.jetbrains.kotlin.platform.isJs
-
-object VersionSpecificApiImpl : VersionSpecificApi {
- override fun isJs(platform: TargetPlatform?): Boolean {
- return platform.isJs()
- }
-
- override fun isWasm(platform: TargetPlatform?): Boolean = false
-
- override var IrFieldBuilder.isFinalVS: Boolean
- get() = modality == Modality.FINAL
- set(value) {
- modality = if (value) Modality.FINAL else Modality.OPEN
- }
-
- override var IrCall.originVS: IrStatementOrigin?
- get() = origin
- set(value) { origin = value }
-
- override var IrConstructor.isPrimaryVS: Boolean
- get() = isPrimary
- set(value) {
- isPrimary = value
- }
-
- override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? {
- return context.referenceClass(
- ClassId(
- FqName(packageName),
- FqName(name),
- false
- )
- )
- }
-
- override fun referenceFunctions(
- context: IrPluginContext,
- packageName: String,
- name: String
- ): Collection {
- return context.referenceFunctions(
- CallableId(
- FqName(packageName),
- Name.identifier(name),
- )
- )
- }
-
- override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter {
- return copyTo(irFunction, origin)
- }
-
- override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter {
- return addExtensionReceiver(type, origin)
- }
-}
diff --git a/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor b/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
deleted file mode 100644
index 61cf7463..00000000
--- a/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
-#
-
-kotlinx.rpc.codegen.RPCCommandLineProcessor
diff --git a/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar b/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
deleted file mode 100644
index 04b0b782..00000000
--- a/compiler-plugin/compiler-plugin-cli/src/main-resources/v_1_7/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
-#
-
-kotlinx.rpc.codegen.RPCCompilerPlugin
diff --git a/compiler-plugin/compiler-plugin-cli/src/main/v_1/kotlinx/rpc/codegen/RPCCompilerPlugin.kt b/compiler-plugin/compiler-plugin-cli/src/main/v_1/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
deleted file mode 100644
index 0b9e62d9..00000000
--- a/compiler-plugin/compiler-plugin-cli/src/main/v_1/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import kotlinx.rpc.codegen.extension.RPCIrExtension
-import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
-import org.jetbrains.kotlin.compiler.plugin.CliOption
-import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
-import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
-import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
-import org.jetbrains.kotlin.config.CompilerConfiguration
-
-@OptIn(ExperimentalCompilerApi::class)
-class RPCCommandLineProcessor : CommandLineProcessor {
- override val pluginId = "kotlinx.rpc.compiler-plugin"
-
- override val pluginOptions = emptyList()
-}
-
-@OptIn(ExperimentalCompilerApi::class)
-class RPCCompilerPlugin : CompilerPluginRegistrar() {
- init {
- VersionSpecificApi.INSTANCE = VersionSpecificApiImpl
- }
-
- override val supportsK2: Boolean = false
-
- override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
- IrGenerationExtension.registerExtension(RPCIrExtension(configuration))
- }
-}
\ No newline at end of file
diff --git a/compiler-plugin/compiler-plugin-cli/src/main/v_1_7/kotlinx/rpc/codegen/RPCCompilerPlugin.kt b/compiler-plugin/compiler-plugin-cli/src/main/v_1_7/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
deleted file mode 100644
index 4ef6ed67..00000000
--- a/compiler-plugin/compiler-plugin-cli/src/main/v_1_7/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import kotlinx.rpc.codegen.extension.RPCIrExtension
-import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
-import org.jetbrains.kotlin.com.intellij.mock.MockProject
-import org.jetbrains.kotlin.compiler.plugin.CliOption
-import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
-import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
-import org.jetbrains.kotlin.config.CompilerConfiguration
-
-class RPCCommandLineProcessor : CommandLineProcessor {
- override val pluginId = "kotlinx.rpc.compiler-plugin"
-
- override val pluginOptions = emptyList()
-}
-
-class RPCCompilerPlugin : ComponentRegistrar {
- init {
- VersionSpecificApi.INSTANCE = VersionSpecificApiImpl
- }
-
- override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
- IrGenerationExtension.registerExtension(project, RPCIrExtension(configuration))
- }
-}
diff --git a/compiler-plugin/compiler-plugin-cli/src/main/v_1_7_2/kotlinx/rpc/codegen/RPCCompilerPlugin.kt b/compiler-plugin/compiler-plugin-cli/src/main/v_1_7_2/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
deleted file mode 100644
index 0ba1a7c9..00000000
--- a/compiler-plugin/compiler-plugin-cli/src/main/v_1_7_2/kotlinx/rpc/codegen/RPCCompilerPlugin.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import kotlinx.rpc.codegen.extension.RPCIrExtension
-import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
-import org.jetbrains.kotlin.com.intellij.mock.MockProject
-import org.jetbrains.kotlin.compiler.plugin.CliOption
-import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
-import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
-import org.jetbrains.kotlin.config.CompilerConfiguration
-
-class RPCCommandLineProcessor : CommandLineProcessor {
- override val pluginId = "kotlinx.rpc.compiler-plugin"
-
- override val pluginOptions = emptyList()
-}
-
-class RPCCompilerPlugin : ComponentRegistrar {
- init {
- VersionSpecificApi.INSTANCE = VersionSpecificApiImpl
- }
-
- override val supportsK2: Boolean = false
-
- override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
- IrGenerationExtension.registerExtension(project, RPCIrExtension(configuration))
- }
-}
diff --git a/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt b/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt
index 5c83460e..58310b45 100644
--- a/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt
+++ b/compiler-plugin/compiler-plugin-common/src/main/core/kotlinx/rpc/codegen/common/Names.kt
@@ -22,12 +22,9 @@ object RpcClassId {
object RpcNames {
val SERVICE_STUB_NAME: Name = Name.identifier("\$rpcServiceStub")
- val SERVICE_STUB_NAME_KSP: Name = Name.identifier("_rpcServiceStub")
const val METHOD_CLASS_NAME_SUFFIX = "\$rpcMethod"
- const val METHOD_CLASS_NAME_SUFFIX_KSP = "_rpcMethod"
}
val Name.rpcMethodClassName: Name get() = Name.identifier("$identifier${RpcNames.METHOD_CLASS_NAME_SUFFIX}")
-val Name.rpcMethodClassNameKsp: Name get() = Name.identifier("$identifier${RpcNames.METHOD_CLASS_NAME_SUFFIX_KSP}")
val Name.rpcMethodName: Name get() = Name.identifier(identifier.removeSuffix(RpcNames.METHOD_CLASS_NAME_SUFFIX))
diff --git a/compiler-plugin/compiler-plugin-k2/build.gradle.kts b/compiler-plugin/compiler-plugin-k2/build.gradle.kts
index bd41c9a1..1040244e 100644
--- a/compiler-plugin/compiler-plugin-k2/build.gradle.kts
+++ b/compiler-plugin/compiler-plugin-k2/build.gradle.kts
@@ -4,7 +4,6 @@
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
import util.enableContextReceivers
-import util.whenKotlinIsAtLeast
plugins {
alias(libs.plugins.conventions.jvm)
@@ -20,8 +19,6 @@ kotlin {
dependencies {
compileOnly(libs.kotlin.reflect)
compileOnly(libs.kotlin.compiler.embeddable)
- project.whenKotlinIsAtLeast(2, 0) {
- compileOnly(libs.serialization.plugin)
- }
+ compileOnly(libs.serialization.plugin)
implementation(projects.compilerPluginCommon)
}
diff --git a/compiler-plugin/compiler-plugin-k2/src/main/v_1/kotlinx/rpc/codegen/Stub.kt b/compiler-plugin/compiler-plugin-k2/src/main/v_1/kotlinx/rpc/codegen/Stub.kt
deleted file mode 100644
index bb176dd5..00000000
--- a/compiler-plugin/compiler-plugin-k2/src/main/v_1/kotlinx/rpc/codegen/Stub.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-// do not delete
diff --git a/core/src/jvmMain/kotlin/kotlinx/rpc/internal/WithRPCStubObject.jvm.kt b/core/src/jvmMain/kotlin/kotlinx/rpc/internal/WithRPCStubObject.jvm.kt
index aec8840f..341d496a 100644
--- a/core/src/jvmMain/kotlin/kotlinx/rpc/internal/WithRPCStubObject.jvm.kt
+++ b/core/src/jvmMain/kotlin/kotlinx/rpc/internal/WithRPCStubObject.jvm.kt
@@ -11,15 +11,17 @@ import kotlin.reflect.KClass
import kotlin.reflect.full.companionObjectInstance
private const val RPC_SERVICE_STUB_SIMPLE_NAME = "\$rpcServiceStub"
-private const val RPC_SERVICE_STUB_KSP_SIMPLE_NAME = "_rpcServiceStub"
@InternalRPCApi
public actual fun findRPCStubProvider(kClass: KClass<*>, resultKClass: KClass): R {
val className = when {
- // as a subclass of the service
- KotlinVersion.CURRENT.isAtLeast(2, 0) -> "${kClass.qualifiedName}\$$RPC_SERVICE_STUB_SIMPLE_NAME"
- // as a standalone class from KSP
- else -> "${kClass.qualifiedName}$RPC_SERVICE_STUB_KSP_SIMPLE_NAME"
+ KotlinVersion.CURRENT.isAtLeast(2, 0) -> {
+ "${kClass.qualifiedName}\$$RPC_SERVICE_STUB_SIMPLE_NAME"
+ }
+
+ else -> {
+ error("kotlinx.rpc runtime is not compatible with Kotlin version prior to 2.0")
+ }
}
val candidate = kClass.java.classLoader
diff --git a/docs/Multiple-Kotlin-Versions-Support.md b/docs/Multiple-Kotlin-Versions-Support.md
index 36723e93..bcd040f5 100644
--- a/docs/Multiple-Kotlin-Versions-Support.md
+++ b/docs/Multiple-Kotlin-Versions-Support.md
@@ -2,7 +2,6 @@
### Compiler specific dependencies releases:
-- ksp: https://github.com/google/ksp/releases
- atomicfu: https://github.com/Kotlin/kotlinx-atomicfu/releases
- serialization: https://github.com/Kotlin/kotlinx.serialization/releases
- coroutines: https://github.com/Kotlin/kotlinx.coroutines/releases
diff --git a/docs/pages/kotlinx-rpc/topics/versions.topic b/docs/pages/kotlinx-rpc/topics/versions.topic
index 58718e55..08ed609c 100644
--- a/docs/pages/kotlinx-rpc/topics/versions.topic
+++ b/docs/pages/kotlinx-rpc/topics/versions.topic
@@ -21,10 +21,7 @@
the following versions of Kotlin are supported:
- 1.7.0, 1.7.10, 1.7.20, 1.7.21, 1.7.22
- 1.8.0, 1.8.10, 1.8.20, 1.8.21, 1.8.22
- 1.9.0, 1.9.10, 1.9.20, 1.9.21, 1.9.22, 1.9.23, 1.9.24, 1.9.25
- 2.0.0, 2.0.10
+ 2.0.0, 2.0.10, 2.0.20, 2.0.21
Our code generation will support these versions (See more on code generation artifacts).
@@ -78,4 +75,4 @@
Such dependencies are managed automatically, and should not be used explicitly.
-
\ No newline at end of file
+
diff --git a/gradle-conventions-settings/settings.gradle.kts b/gradle-conventions-settings/settings.gradle.kts
index bf3d8289..243312dc 100644
--- a/gradle-conventions-settings/settings.gradle.kts
+++ b/gradle-conventions-settings/settings.gradle.kts
@@ -9,8 +9,4 @@ apply(from = "src/main/kotlin/settings-conventions.settings.gradle.kts")
val kotlinVersion: KotlinVersion by extra
-if (kotlinVersion.isAtLeast(1, 9, 0)) {
- include(":develocity")
-} else {
- include(":empty")
-}
+include(":develocity")
diff --git a/gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts b/gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts
index 69cdd7de..92a637e6 100644
--- a/gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts
+++ b/gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts
@@ -35,7 +35,6 @@ object SettingsConventions {
const val LIBRARY_VERSION_ENV_VAR_NAME = "LIBRARY_VERSION"
const val EAP_VERSION_ENV_VAR_NAME = "EAP_VERSION"
- const val KSP_VERSION_ALIAS = "ksp"
const val LIBRARY_CORE_VERSION_ALIAS = "kotlinx-rpc"
const val KOTLIN_VERSION_ALIAS = "kotlin-lang"
@@ -221,18 +220,8 @@ dependencyResolutionManagement {
logger.info("Resolved compiler specific dependencies versions (Kotlin $kotlinVersion):")
lookupTable.forEach { (name, version) ->
- val fullVersion = when (name) {
- SettingsConventions.KSP_VERSION_ALIAS -> {
- "$kotlinVersion-${version}"
- }
-
- else -> {
- version
- }
- }
-
- logger.info("$name -> $fullVersion")
- version(name, fullVersion)
+ logger.info("$name -> $version")
+ version(name, version)
}
}
}
diff --git a/gradle-conventions-settings/src/main/kotlin/util/KotlinVersion.kt b/gradle-conventions-settings/src/main/kotlin/util/KotlinVersion.kt
index 5cad073d..6f363b5a 100644
--- a/gradle-conventions-settings/src/main/kotlin/util/KotlinVersion.kt
+++ b/gradle-conventions-settings/src/main/kotlin/util/KotlinVersion.kt
@@ -90,6 +90,7 @@ private val directoryNameRegex = "^(latest|(v|pre)(_\\d){1,3}\\d?)$".toRegex()
data class ActionApplied(val applied: Boolean)
+@Suppress("unused")
inline fun ExtensionAware.whenKotlinIsAtLeast(
major: Int,
minor: Int,
diff --git a/gradle-conventions-settings/src/main/kotlin/util/TargetUtils.kt b/gradle-conventions-settings/src/main/kotlin/util/TargetUtils.kt
index 072bf0bb..c30f8cc5 100644
--- a/gradle-conventions-settings/src/main/kotlin/util/TargetUtils.kt
+++ b/gradle-conventions-settings/src/main/kotlin/util/TargetUtils.kt
@@ -18,24 +18,6 @@ private fun KotlinMultiplatformExtension.configureTargets(config: ProjectKotlinC
if (config.native) {
val nativeTargets = config.nativeTargets(this)
targets.addAll(nativeTargets)
-
- // TLDR: Default hierarchy template is enabled by default since 1.9.20
- //
- // https://kotlinlang.org/docs/multiplatform-hierarchy.html#default-hierarchy-template
- if (nativeTargets.isNotEmpty() && !config.kotlinVersion.isAtLeast(1, 9, 20)) {
- val commonMain = sourceSets.findByName("commonMain")!!
- val commonTest = sourceSets.findByName("commonTest")!!
- val nativeMain = sourceSets.create("nativeMain")
- val nativeTest = sourceSets.create("nativeTest")
-
- nativeMain.dependsOn(commonMain)
- nativeTest.dependsOn(commonTest)
-
- nativeTargets.forEach { target ->
- sourceSets.findByName("${target.name}Main")?.dependsOn(nativeMain)
- sourceSets.findByName("${target.name}Test")?.dependsOn(nativeTest)
- }
- }
}
if (config.jvm) {
diff --git a/gradle-conventions-settings/src/main/kotlin/util/atomicfu.kt b/gradle-conventions-settings/src/main/kotlin/util/atomicfu.kt
index 45acf13b..018ec503 100644
--- a/gradle-conventions-settings/src/main/kotlin/util/atomicfu.kt
+++ b/gradle-conventions-settings/src/main/kotlin/util/atomicfu.kt
@@ -7,9 +7,5 @@ package util
import org.gradle.api.Project
fun Project.applyAtomicfuPlugin() {
- if (libs.versions.atomicfu.get() >= "0.24.0") {
- plugins.apply(libs.plugins.atomicfu.new.get().pluginId)
- } else {
- plugins.apply(libs.plugins.atomicfu.old.get().pluginId)
- }
+ plugins.apply(libs.plugins.atomicfu.get().pluginId)
}
diff --git a/gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version.gradle.kts b/gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version.gradle.kts
index 36d1b37e..6c37f5a9 100644
--- a/gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version.gradle.kts
+++ b/gradle-conventions/latest-only/src/main/kotlin/conventions-kotlin-version.gradle.kts
@@ -18,8 +18,8 @@ import util.withKotlinKmpExtension
* This makes our tests execute against the latest compiler plugin version (for example, with K2 instead of K1).
*/
fun KotlinCommonCompilerOptions.setProjectLanguageVersion() {
- languageVersion.set(KotlinVersion.KOTLIN_1_7)
- apiVersion.set(KotlinVersion.KOTLIN_1_7)
+ languageVersion.set(KotlinVersion.KOTLIN_2_0)
+ apiVersion.set(KotlinVersion.KOTLIN_2_0)
}
withKotlinJvmExtension {
diff --git a/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts b/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts
index f346c087..5e933c4d 100644
--- a/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts
+++ b/gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts
@@ -75,26 +75,6 @@ fun KotlinSourceSet.configureResources(sourceSetPath: Path) {
val versionNames = listOfNotNull(Dir.CORE_SOURCE_DIR, mostSpecificApplicable?.name)
resources.srcDirs(versionNames.map { resourcesDir.resolve(it).toFile() })
-
- // 'resources' property does not work alone in gradle 7.5.1 with kotlin 1.7.* and 1.8.* (no idea why),
- // so we adjust task contents as well
- if (!kotlinVersion.isAtLeast(1, 9)) {
- // only works for jvm projects
- val resourcesTaskName = if (name == Dir.MAIN_SOURCE_SET) Dir.PROCESS_RESOURCES else Dir.PROCESS_TEST_RESOURCES
- tasks.withType().configureEach {
- if (name != resourcesTaskName) {
- return@configureEach
- }
-
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
-
- from(versionNames.map { resourcesDir.resolve(it) })
- include {
- // double check if the files are the right ones
- it.file.toPath().toAbsolutePath().startsWith(parent)
- }
- }
- }
}
withKotlinJvmExtension {
diff --git a/gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts b/gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts
index 77009269..d4a3d615 100644
--- a/gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts
+++ b/gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts
@@ -38,27 +38,23 @@ fun PublishingExtension.configurePublication() {
null
}
- // separate function is needed for different gradle versions
- // in 7.6 `Configuration` argument is `this`, in 8.* it is a first argument (hence `it`)
- val onPublication: (MavenPublication) -> Unit = { publication ->
- publication.pom.configureMavenCentralMetadata()
- publication.signPublicationIfKeyPresent()
+ publications.withType(MavenPublication::class).all {
+ pom.configureMavenCentralMetadata()
+ signPublicationIfKeyPresent()
if (javadocJar != null) {
- publication.artifact(javadocJar)
+ artifact(javadocJar)
}
// mainly for kotlinMultiplatform publication
- publication.setPublicArtifactId(project)
+ setPublicArtifactId(project)
if (!isGradlePlugin) {
- publication.fixModuleMetadata(project)
+ fixModuleMetadata(project)
}
- logger.info("Project ${project.name} -> Publication configured: ${publication.name}")
+ logger.info("Project ${project.name} -> Publication configured: $name")
}
- publications.withType(MavenPublication::class).all(onPublication)
-
tasks.withType().configureEach {
dependsOn(tasks.withType())
}
diff --git a/gradle-conventions/src/main/pre_1_9_20/util/contextReceivers.kt b/gradle-conventions/src/main/pre_1_9_20/util/contextReceivers.kt
deleted file mode 100644
index c162bae3..00000000
--- a/gradle-conventions/src/main/pre_1_9_20/util/contextReceivers.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package util
-
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.withType
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-fun Project.enableContextReceivers() {
- tasks.withType().all {
- kotlinOptions {
- freeCompilerArgs += "-Xcontext-receivers"
- }
- }
-}
diff --git a/gradle-conventions/src/main/pre_1_9_20/util/wasm.kt b/gradle-conventions/src/main/pre_1_9_20/util/wasm.kt
deleted file mode 100644
index 11504d03..00000000
--- a/gradle-conventions/src/main/pre_1_9_20/util/wasm.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package util
-
-fun ProjectKotlinConfig.configureWasm() {
- // do nothing
-}
diff --git a/gradle-conventions/src/main/pre_1_9_25/util/contextReceivers.kt b/gradle-conventions/src/main/pre_1_9_25/util/contextReceivers.kt
deleted file mode 100644
index b435321c..00000000
--- a/gradle-conventions/src/main/pre_1_9_25/util/contextReceivers.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package util
-
-import org.gradle.api.Project
-import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
-
-fun Project.enableContextReceivers() {
- withKotlinJvmExtension {
- compilerOptions {
- freeCompilerArgs.add("-Xcontext-receivers")
- }
- }
-
- withKotlinKmpExtension {
- @OptIn(ExperimentalKotlinGradlePluginApi::class)
- compilerOptions {
- freeCompilerArgs.add("-Xcontext-receivers")
- }
- }
-}
diff --git a/gradle-conventions/src/main/pre_1_9_25/util/wasm.kt b/gradle-conventions/src/main/pre_1_9_25/util/wasm.kt
deleted file mode 100644
index 11504d03..00000000
--- a/gradle-conventions/src/main/pre_1_9_25/util/wasm.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package util
-
-fun ProjectKotlinConfig.configureWasm() {
- // do nothing
-}
diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts
index ac0f11eb..ea652c77 100644
--- a/gradle-plugin/build.gradle.kts
+++ b/gradle-plugin/build.gradle.kts
@@ -40,19 +40,6 @@ gradlePlugin {
implementationClass = "kotlinx.rpc.RPCGradlePlugin"
description = """
The plugin ensures correct RPC configurations for your project, that will allow proper code generation.
- Additionally, it applies the kotlinx.rpc BOM file for the project.
- """.trimIndent()
- }
- }
-
- plugins {
- create("platform") {
- id = "org.jetbrains.kotlinx.rpc.platform"
-
- displayName = "kotlinx.rpc Platform Plugin"
- implementationClass = "kotlinx.rpc.RPCPlatformPlugin"
- description = """
- Applies the kotlinx.rpc BOM file for the project.
""".trimIndent()
}
}
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCGradlePlugin.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCGradlePlugin.kt
index 7080aaf5..fbbbdaa6 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCGradlePlugin.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCGradlePlugin.kt
@@ -4,35 +4,11 @@
package kotlinx.rpc
-import kotlinx.rpc.RPCPluginConst.GROUP_ID
-import kotlinx.rpc.RPCPluginConst.KSP_PLUGIN_ARTIFACT_ID
-import kotlinx.rpc.RPCPluginConst.KSP_PLUGIN_ID
-import kotlinx.rpc.RPCPluginConst.KSP_PLUGIN_MODULE
-import kotlinx.rpc.RPCPluginConst.kotlinVersion
-import kotlinx.rpc.RPCPluginConst.libraryKotlinPrefixedVersion
-import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.Configuration
-import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
-import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin
-
-internal data class RPCConfig(
- val kotlinLanguageVersion: KotlinVersion,
-)
class RPCGradlePlugin : Plugin {
override fun apply(target: Project) {
- if (!target.isInternalDevelopment) {
- target.plugins.apply(RPCPlatformPlugin::class.java)
- }
-
- // Will apply only if the KSP plugin is present.
- // While the K1 plugin is not present, it is alright to leave it this way.
- // It will generate redundant code, but it is not critical,
- // since that code will not be used, and K1 will shortly remove KSP altogether
- applyKspPlugin(target, target.isInternalDevelopment)
-
applyCompilerPlugin(target)
}
@@ -42,58 +18,4 @@ class RPCGradlePlugin : Plugin {
target.plugins.apply(CompilerPluginBackend::class.java)
target.plugins.apply(CompilerPluginCli::class.java)
}
-
- private fun applyKspPlugin(target: Project, isInternalDevelopment: Boolean) {
- withKspPlugin(target) {
- val libraryKspPlugin = when {
- isInternalDevelopment -> KSP_PLUGIN_MODULE
-
- else -> "$GROUP_ID:$KSP_PLUGIN_ARTIFACT_ID:$libraryKotlinPrefixedVersion"
- }
-
- val isKmpProject = target.extensions.findByType(KotlinMultiplatformExtension::class.java) != null
-
- // separate function is needed for different gradle versions
- // in 7.6 `Configuration` argument is `this`, in 8.* it is a first argument (hence `it`)
- val onConfiguration: (Configuration) -> Unit = { kspConfiguration ->
- target.dependencies.add(kspConfiguration.name, libraryKspPlugin)
- }
-
- target.configurations
- // `matching` and `all` functions are live in gradle, without them code would not work
- .matching { config ->
- val name = config.name
- // all ksp configurations start with ksp prefix
- name.startsWith("ksp") &&
- // filter out non-compilation configs
- !name.contains("metadata") &&
- !name.contains("Metadata") &&
- !name.contains("ProcessorClasspath") &&
- !name.contains("GeneratedByKsp") &&
- !name.contains("PluginClasspath") &&
- // ksp and kspTest configurations are deprecated for kmp project,
- // target specific configurations are present instead
- !(isKmpProject && (name == "ksp" || name == "kspTest"))
- }
- .all(onConfiguration)
- }
- }
-
- private fun withKspPlugin(target: Project, action: Action) {
- // separate function is needed for different gradle versions
- // in 7.6 `Plugin` argument is `this`, in 8.* it is a first argument (hence `it`)
- val onPlugin: (Plugin) -> Unit = {
- val plugin = it as KotlinCompilerPluginSupportPlugin
-
- val version = plugin.getPluginArtifact().version
- if (version?.startsWith(kotlinVersion) != true) {
- error("Invalid KSP Gradle Plugin version: $version. Expected version to start with $kotlinVersion")
- }
-
- action.execute(Unit)
- }
-
- // `withId` is live, so order of plugins can be arbitrary
- target.plugins.withId(KSP_PLUGIN_ID, onPlugin)
- }
}
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPlatformPlugin.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPlatformPlugin.kt
deleted file mode 100644
index 8bc91188..00000000
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPlatformPlugin.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc
-
-import kotlinx.rpc.RPCPluginConst.BOM_ARTIFACT_ID
-import kotlinx.rpc.RPCPluginConst.GROUP_ID
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.api.artifacts.Configuration
-
-class RPCPlatformPlugin : Plugin {
- override fun apply(target: Project) {
- val bomDependency = "${GROUP_ID}:${BOM_ARTIFACT_ID}:${PLUGIN_VERSION}"
-
- val matcher: (Configuration) -> Boolean = { conf ->
- conf.name in knownConfigurations
- }
-
- target.configurations.matching(matcher).all {
- target.dependencies.add(name, target.dependencies.platform(bomDependency))
- }
- }
-
- companion object {
- private const val IMPLEMENTATION = "implementation"
- private const val COMMON_IMPLEMENTATION = "commonMainImplementation"
-
- private val knownConfigurations = setOf(IMPLEMENTATION, COMMON_IMPLEMENTATION)
- }
-}
diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPluginConst.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPluginConst.kt
index 11195cdd..66f172cd 100644
--- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPluginConst.kt
+++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RPCPluginConst.kt
@@ -11,19 +11,12 @@ import org.jetbrains.kotlin.gradle.utils.loadPropertyFromResources
object RPCPluginConst {
const val GROUP_ID = "org.jetbrains.kotlinx"
-
- const val KSP_PLUGIN_MODULE = "${GROUP_ID}:ksp-plugin"
-
- const val KSP_PLUGIN_ID = "com.google.devtools.ksp"
-
const val PLUGIN_ID = "org.jetbrains.kotlinx.rpc.plugin"
const val COMPILER_PLUGIN_ARTIFACT_ID = "kotlinx-rpc-compiler-plugin"
- const val KSP_PLUGIN_ARTIFACT_ID = "kotlinx-rpc-ksp-plugin"
- const val BOM_ARTIFACT_ID = "kotlinx-rpc-bom"
const val INTERNAL_DEVELOPMENT_PROPERTY = "kotlinx.rpc.plugin.internalDevelopment"
- val kotlinVersion by lazy { loadKotlinVersion() }
+ private val kotlinVersion by lazy { loadKotlinVersion() }
val libraryKotlinPrefixedVersion by lazy {
"$kotlinVersion-$PLUGIN_VERSION"
diff --git a/gradle.properties b/gradle.properties
index 37d532f7..7d96cd58 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,13 +3,8 @@
#
kotlin.code.style=official
-kotlin.js.compiler=ir
kotlin.native.ignoreDisabledTargets=true
-kotlin.native.ignoreIncorrectDependencies=true
-
-# for 1.7.* versions
-kotlin.mpp.stability.nowarn=true
kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1260a53f..bbf90758 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -4,6 +4,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/internal/RPCClientConnector.kt b/krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/internal/RPCClientConnector.kt
index 2a540719..b298c645 100644
--- a/krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/internal/RPCClientConnector.kt
+++ b/krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/internal/RPCClientConnector.kt
@@ -14,11 +14,9 @@ internal sealed interface CallSubscriptionId {
val callId: String,
) : CallSubscriptionId
- @Suppress("ConvertObjectToDataObject") // not supported in 1.8.22 or earlier
- object Protocol : CallSubscriptionId
+ data object Protocol : CallSubscriptionId
- @Suppress("ConvertObjectToDataObject") // not supported in 1.8.22 or earlier
- object Generic : CallSubscriptionId
+ data object Generic : CallSubscriptionId
}
internal class RPCClientConnector private constructor(
diff --git a/krpc/krpc-core/api/krpc-core.api b/krpc/krpc-core/api/krpc-core.api
index 06470faf..5b0242da 100644
--- a/krpc/krpc-core/api/krpc-core.api
+++ b/krpc/krpc-core/api/krpc-core.api
@@ -77,7 +77,7 @@ public final class kotlinx/rpc/krpc/RPCTransportMessage$StringMessage : kotlinx/
public final fun getValue ()Ljava/lang/String;
}
-public final class kotlinx/rpc/krpc/StreamScope : kotlinx/rpc/internal/utils/AutoCloseable {
+public final class kotlinx/rpc/krpc/StreamScope : java/lang/AutoCloseable {
public fun close ()V
}
diff --git a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/StreamScope.kt b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/StreamScope.kt
index fa8f7955..d68c479f 100644
--- a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/StreamScope.kt
+++ b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/StreamScope.kt
@@ -5,11 +5,9 @@
package kotlinx.rpc.krpc
import kotlinx.coroutines.*
-import kotlinx.rpc.internal.utils.AutoCloseable
import kotlinx.rpc.internal.utils.ExperimentalRPCApi
import kotlinx.rpc.internal.utils.InternalRPCApi
import kotlinx.rpc.internal.utils.map.ConcurrentHashMap
-import kotlinx.rpc.internal.utils.use
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
diff --git a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/CancellationType.kt b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/CancellationType.kt
index 35927811..ce038da2 100644
--- a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/CancellationType.kt
+++ b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/CancellationType.kt
@@ -17,11 +17,8 @@ public enum class CancellationType(override val uniqueIndex: Int) : IndexedEnum
;
internal companion object {
- @Suppress("EnumValuesSoftDeprecate") // cannot use entries in Kotlin 1.8.10 or earlier
- private val values = values()
-
fun valueOfNull(value: String): CancellationType? {
- return values.find { it.name == value }
+ return entries.find { it.name == value }
}
}
}
diff --git a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCConnector.kt b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCConnector.kt
index b78018cf..96667604 100644
--- a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCConnector.kt
+++ b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCConnector.kt
@@ -10,7 +10,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.rpc.internal.utils.InternalRPCApi
-import kotlinx.rpc.internal.utils.hex.toHexStringInternal
import kotlinx.rpc.krpc.RPCTransport
import kotlinx.rpc.krpc.RPCTransportMessage
import kotlinx.rpc.krpc.internal.logging.CommonLogger
@@ -230,21 +229,20 @@ public class RPCConnector(
const val SERVER_ROLE = "Server"
const val CLIENT_ROLE = "Client"
+ @OptIn(ExperimentalStdlibApi::class)
private fun RPCTransportMessage.dump(): String {
return when (this) {
is RPCTransportMessage.StringMessage -> value
- is RPCTransportMessage.BinaryMessage -> value.toHexStringInternal()
+ is RPCTransportMessage.BinaryMessage -> value.toHexString()
}
}
}
}
-
-@Suppress("ConvertObjectToDataObject") // not supported in 1.8.22 or earlier
private sealed interface HandlerResult {
- object Success : HandlerResult
+ data object Success : HandlerResult
- object NoSubscription : HandlerResult
+ data object NoSubscription : HandlerResult
data class Failure(val cause: Throwable?) : HandlerResult
}
diff --git a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPlugin.kt b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPlugin.kt
index 6abd927d..f2303f1a 100644
--- a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPlugin.kt
+++ b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPlugin.kt
@@ -57,8 +57,7 @@ public enum class RPCPlugin(
/**
* A set of all plugins for the current version of the library.
*/
- @Suppress("EnumValuesSoftDeprecate") // cannot use entries in Kotlin 1.8.10 or earlier
- public val ALL: Set = RPCPlugin.values().toSet() - UNKNOWN
+ public val ALL: Set = RPCPlugin.entries.toSet() - UNKNOWN
}
}
diff --git a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPluginKey.kt b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPluginKey.kt
index 7d38b284..6e96221f 100644
--- a/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPluginKey.kt
+++ b/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/RPCPluginKey.kt
@@ -56,8 +56,7 @@ public enum class RPCPluginKey(override val uniqueIndex: Int, private val associ
@InternalRPCApi
public companion object {
- @Suppress("EnumValuesSoftDeprecate") // cannot use entries in Kotlin 1.8.10 or earlier
- public val ALL: Set = RPCPluginKey.values().toSet() - UNKNOWN
+ public val ALL: Set = RPCPluginKey.entries.toSet() - UNKNOWN
}
}
diff --git a/krpc/krpc-server/src/jvmMain/kotlin/kotlinx/rpc/krpc/server/internal/RPCServerConnector.kt b/krpc/krpc-server/src/jvmMain/kotlin/kotlinx/rpc/krpc/server/internal/RPCServerConnector.kt
index 815221cf..0323a115 100644
--- a/krpc/krpc-server/src/jvmMain/kotlin/kotlinx/rpc/krpc/server/internal/RPCServerConnector.kt
+++ b/krpc/krpc-server/src/jvmMain/kotlin/kotlinx/rpc/krpc/server/internal/RPCServerConnector.kt
@@ -11,11 +11,9 @@ import kotlinx.serialization.SerialFormat
internal sealed interface MessageKey {
data class Service(val serviceTypeString: String): MessageKey
- @Suppress("ConvertObjectToDataObject") // not supported in 1.8.22 or earlier
- object Protocol: MessageKey
+ data object Protocol: MessageKey
- @Suppress("ConvertObjectToDataObject") // not supported in 1.8.22 or earlier
- object Generic: MessageKey
+ data object Generic: MessageKey
}
internal class RPCServerConnector private constructor(
diff --git a/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/ProtocolTest.kt b/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/ProtocolTest.kt
index 892408fc..9fbaaf5a 100644
--- a/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/ProtocolTest.kt
+++ b/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/ProtocolTest.kt
@@ -6,7 +6,6 @@ package kotlinx.rpc.krpc.test
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.launch
-import kotlinx.rpc.internal.utils.hex.hexToByteArrayInternal
import kotlinx.rpc.krpc.RPCTransportMessage
import kotlinx.rpc.krpc.internal.RPCPlugin
import kotlinx.rpc.krpc.rpcClientConfig
@@ -114,6 +113,7 @@ class ProtocolTest : ProtocolTestBase() {
// no checks here, we just make sure that test does not fail on double UNKNOWN key values
}
+ @OptIn(ExperimentalStdlibApi::class)
@Test
fun testMultipleUnknownPluginParamEntriesForServerProtobuf() = runTest(
serverConfig = rpcServerConfig {
@@ -132,7 +132,7 @@ class ProtocolTest : ProtocolTestBase() {
// same value as testMultipleUnknownPluginParamEntriesForServer but in protobuf format
val clientHandshakeMessage = RPCTransportMessage.BinaryMessage(
- "0a426f72672e6a6574627261696e732e6b7270632e696e7465726e616c2e7472616e73706f72742e52504350726f746f636f6c4d6573736167652e48616e647368616b6512310801108180feffffffffffff011a1008feff01120a66726f6d2033323736361a1008ffff01120a66726f6d203332373637".hexToByteArrayInternal() // 32766 and 32767 are unknown to server
+ "0a426f72672e6a6574627261696e732e6b7270632e696e7465726e616c2e7472616e73706f72742e52504350726f746f636f6c4d6573736167652e48616e647368616b6512310801108180feffffffffffff011a1008feff01120a66726f6d2033323736361a1008ffff01120a66726f6d203332373637".hexToByteArray() // 32766 and 32767 are unknown to server
)
transport.client.send(clientHandshakeMessage)
diff --git a/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/WireSamplingTestScope.kt b/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/WireSamplingTestScope.kt
index 5ed99e37..594bfda9 100644
--- a/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/WireSamplingTestScope.kt
+++ b/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/WireSamplingTestScope.kt
@@ -12,7 +12,6 @@ import kotlinx.coroutines.test.TestResult
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import kotlinx.rpc.RemoteService
-import kotlinx.rpc.internal.utils.hex.hexToByteArrayInternal
import kotlinx.rpc.internal.utils.hex.hexToReadableBinary
import kotlinx.rpc.krpc.RPCTransportMessage
import kotlinx.rpc.krpc.internal.logging.CommonLogger
@@ -173,10 +172,11 @@ class WireSamplingTestScope(private val sampleName: String, scope: TestScope) :
oldServerToolkit.stop()
}
+ @OptIn(ExperimentalStdlibApi::class)
private fun String.toTransportMessage(format: SamplingFormat): RPCTransportMessage {
return when (format) {
SamplingFormat.Json -> RPCTransportMessage.StringMessage(this)
- SamplingFormat.Protobuf -> RPCTransportMessage.BinaryMessage(hexToByteArrayInternal())
+ SamplingFormat.Protobuf -> RPCTransportMessage.BinaryMessage(hexToByteArray())
}
}
@@ -269,8 +269,7 @@ enum class SamplingFormat(val commentBinaryOutput: Boolean, val init: RPCSerialF
;
companion object {
- @Suppress("EnumValuesSoftDeprecate") // .entries dont work on Kotlin pre 1.8.20
- val ALL = SamplingFormat.values()
+ val ALL: Array = SamplingFormat.entries.toTypedArray()
}
}
diff --git a/ksp-plugin/build.gradle.kts b/ksp-plugin/build.gradle.kts
deleted file mode 100644
index aa8520fd..00000000
--- a/ksp-plugin/build.gradle.kts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
-
-val kotlinVersionFull: String by extra
-val rpcVersion: String = libs.versions.kotlinx.rpc.get()
-
-allprojects {
- group = "org.jetbrains.kotlinx"
- version = "$kotlinVersionFull-$rpcVersion"
-}
-
-plugins {
- alias(libs.plugins.conventions.jvm)
-}
-
-dependencies {
- implementation(libs.ksp.runtime.api)
-}
-
-kotlin {
- explicitApi = ExplicitApiMode.Disabled
-}
diff --git a/ksp-plugin/gradle.properties b/ksp-plugin/gradle.properties
deleted file mode 120000
index 7677fb73..00000000
--- a/ksp-plugin/gradle.properties
+++ /dev/null
@@ -1 +0,0 @@
-../gradle.properties
\ No newline at end of file
diff --git a/ksp-plugin/settings.gradle.kts b/ksp-plugin/settings.gradle.kts
deleted file mode 100644
index e8750b25..00000000
--- a/ksp-plugin/settings.gradle.kts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-rootProject.name = "ksp-plugin"
-
-enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
-
-pluginManagement {
- includeBuild("../gradle-conventions")
- includeBuild("../gradle-conventions-settings")
-}
-
-plugins {
- id("settings-conventions")
- id("conventions-develocity")
-}
-
-includeRootAsPublic()
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/ACodeGenerationException.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/ACodeGenerationException.kt
deleted file mode 100644
index 72814052..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/ACodeGenerationException.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("detekt:all")
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.symbol.KSDeclaration
-
-sealed class ACodeGenerationException(
- initMessage: String? = null,
- declaration: KSDeclaration? = null,
-) : Exception() {
- override val message: String = run {
- val serviceInfo = declaration?.qualifiedName?.let { " [${it.asString()}]" } ?: ""
-
- "[RPC Codegen]$serviceInfo $initMessage"
- }
-}
-
-class CodeGenerationException(message: String, declaration: KSDeclaration? = null) :
- ACodeGenerationException(message, declaration)
-
-class MutableFieldCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service field can not be mutable", declaration)
-
-class FieldExtensionReceiverCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service field can not have extension receiver", declaration)
-
-class ForbiddenFieldTypeCodeGenerationException(declaration: KSDeclaration? = null) : ACodeGenerationException(
- initMessage = "Only Flow, SharedFlow and StateFlow fields are allowed in a RemoteService",
- declaration = declaration
-)
-
-class InvalidFieldNameCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service field's name cannot contain \$ symbol", declaration)
-
-class InvalidMethodNameCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service method's name cannot contain \$ symbol", declaration)
-
-class UnresolvedMethodReturnTypeCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("Failed to resolve method's returnType", declaration)
-
-class MethodDefaultImplementationCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service method can not have default implementation", declaration)
-
-class AbsentSuspendMethodModifierCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service method must have 'suspend' modifier", declaration)
-
-class ForbiddenMethodModifierCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException(
- initMessage = "RPC Service method can not have any of these modifiers: ${RPCSymbolProcessor.DENY_LIST_FUNCTION_MODIFIERS.joinToString()}",
- declaration = declaration
- )
-
-class MethodExtensionReceiverCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service method can not have extension receiver", declaration)
-
-class MethodTypeParametersCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service method can not have type parameters", declaration)
-
-class AbsentQualifiedNameCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("Expected service qualified name", declaration)
-
-class AbsentShortNameCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("Expected function argument name", declaration)
-
-class ForbiddenServiceInterfaceModifierCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException(
- initMessage = "RPC Service interface can not have any of these modifiers: ${RPCSymbolProcessor.DENY_LIST_SERVICE_MODIFIERS.joinToString()}",
- declaration = declaration
- )
-
-class ServiceInterfaceTypeParametersCodeGenerationException(declaration: KSDeclaration? = null) :
- ACodeGenerationException("RPC Service interface can not have type parameters", declaration)
-
-inline fun codegenError(declaration: KSDeclaration? = null): Nothing {
- codegenError(E::class.java, declaration)
-}
-
-fun codegenError(errorClass: Class, declaration: KSDeclaration? = null): Nothing {
- throw errorClass.constructors.first().newInstance(declaration) as Exception
-}
-
-fun codegenError(message: String, declaration: KSDeclaration? = null): Nothing {
- throw CodeGenerationException(message, declaration)
-}
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/CodeWriter.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/CodeWriter.kt
deleted file mode 100644
index 68a157e5..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/CodeWriter.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import java.io.BufferedWriter
-
-fun BufferedWriter.codeWriter() = CodeWriter(this)
-
-class CodeWriter(private val bufferedWriter: BufferedWriter, private val depth: Int = 0) {
- fun newLine() {
- bufferedWriter.newLine()
- }
-
- fun writeLine(str: String) {
- bufferedWriter.write(TAB.repeat(depth) + str)
- bufferedWriter.newLine()
- }
-
- fun flush() {
- bufferedWriter.flush()
- }
-
- fun nested() = CodeWriter(bufferedWriter, depth + 1)
-
- companion object {
- private const val TAB = " "
- }
-}
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCClientServiceGenerator.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCClientServiceGenerator.kt
deleted file mode 100644
index 946ba9b4..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCClientServiceGenerator.kt
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("detekt:all")
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.processing.CodeGenerator
-import com.google.devtools.ksp.processing.Dependencies
-import com.google.devtools.ksp.symbol.KSType
-
-class RPCClientServiceGenerator(private val codegen: CodeGenerator) {
- fun generate(service: RPCServiceDeclaration) {
- val writer = codegen.createNewFile(
- dependencies = Dependencies(aggregating = true, service.file),
- packageName = service.packageName,
- fileName = service.simpleName.withStubSuffix(),
- extensionName = "kt",
- ).bufferedWriter(charset = Charsets.UTF_8).codeWriter()
-
- generate(writer, service)
- }
-
- private fun generate(
- writer: CodeWriter,
- service: RPCServiceDeclaration,
- ) {
- writer.writeLine("@file:Suppress(\"RedundantUnitReturnType\", \"RemoveRedundantQualifierName\", \"USELESS_CAST\", \"UNCHECKED_CAST\", \"ClassName\", \"MemberVisibilityCanBePrivate\", \"KotlinRedundantDiagnosticSuppress\", \"UnusedImport\", \"detekt.all\")")
- writer.writeLine("@file:OptIn(InternalRPCApi::class)")
- writer.newLine()
-
- if (service.packageName.isNotBlank()) {
- writer.writeLine("package ${service.packageName}")
- writer.newLine()
- }
-
- generateImports(writer, service)
-
- generateStubClass(service, writer)
-
- writer.flush()
- }
-
- private fun generateStubClass(service: RPCServiceDeclaration, writer: CodeWriter) {
- writer.writeLine("@Deprecated(level = DeprecationLevel.HIDDEN, message = \"Internal kotlinx.rpc API, do not use!\")")
- writer.writeLine("class ${service.simpleName.withStubSuffix()} {")
-
- with(writer.nested()) {
- service.functions.forEach {
- it.generateFunctionClass(this)
- }
-
- writeLine("companion object")
- }
-
- writer.writeLine("}")
- }
-
- private fun generateImports(writer: CodeWriter, service: RPCServiceDeclaration) {
- writer.writeLine("import kotlinx.coroutines.*")
- writer.writeLine("import kotlinx.serialization.*")
- writer.writeLine("import kotlinx.rpc.internal.*")
- writer.writeLine("import kotlinx.rpc.*")
- writer.writeLine("import kotlin.reflect.typeOf")
- writer.writeLine("import kotlin.coroutines.CoroutineContext")
- service.collectRootImports().distinctBy { it.simpleName.asString() }.forEach {
- writer.writeLine("import ${it.simpleName.asString()}")
- }
- writer.newLine()
- writer.newLine()
- }
-
- private fun KSType.toCode(): String {
- val qualifier = declaration.qualifiedName?.asString()
- ?: codegenError(declaration)
-
- val arguments = arguments.joinToString {
- val variance =
- it.variance.label.let { variance -> if (variance.isBlank() || variance == "*") "" else "$variance " }
- "$variance${it.type?.resolve()?.toCode() ?: ""}"
- }.let {
- if (it.isEmpty()) "" else "<$it>"
- }
-
- val nullability = when {
- isMarkedNullable -> "?"
- else -> ""
- }
-
- return "$qualifier$arguments$nullability"
- }
-
-
- private fun RPCServiceDeclaration.Function.generateFunctionClass(writer: CodeWriter) {
- writer.writeLine("@Serializable")
- val classOrObject = if (argumentTypes.isEmpty()) "object" else "class"
- writer.writeLine("$classOrObject ${name.functionGeneratedClass()}${if (argumentTypes.isEmpty()) "" else "("}")
- if (argumentTypes.isNotEmpty()) {
- with(writer.nested()) {
- argumentTypes.forEach { arg ->
- val prefix = if (arg.isContextual) {
- "@Contextual "
- } else {
- ""
- }
-
- val type = if (arg.isVararg) "List<${arg.type.toCode()}>" else arg.type.toCode()
- writeLine("${prefix}val ${arg.name}: $type,")
- }
- }
- writer.writeLine(")")
- }
- writer.newLine()
- }
-}
-
-fun String.withStubSuffix() = "${this}_rpcServiceStub"
-
-fun String.functionGeneratedClass() = "${this}_rpcMethod"
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCServiceDeclaration.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCServiceDeclaration.kt
deleted file mode 100644
index 8b27b23c..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCServiceDeclaration.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.symbol.KSDeclaration
-import com.google.devtools.ksp.symbol.KSFile
-import com.google.devtools.ksp.symbol.KSType
-
-class RPCServiceDeclaration(
- private val declaration: KSDeclaration,
- val simpleName: String,
- val fullName: String,
- val packageName: String,
- val functions: List,
- val fields: List,
- val file: KSFile,
-) {
- class Function(
- val name: String,
- val argumentTypes: List,
- val returnType: KSType,
- ) {
- class Argument(
- val name: String,
- val type: KSType,
- val isVararg: Boolean,
- val isContextual: Boolean,
- )
-
- fun collectRootImports(): List {
- return (argumentTypes.map { it.type } + returnType).mapNotNull { it.asRootType() }
- }
- }
-
- class FlowField(
- val name: String,
- val type: KSType,
- val flowType: Type,
- val isEager: Boolean,
- ) {
- enum class Type {
- Plain, Shared, State;
- }
-
- fun collectRootImports(): List {
- return listOfNotNull(type.asRootType())
- }
- }
-
- fun collectRootImports(): List {
- return functions.flatMap { it.collectRootImports() } +
- fields.flatMap { it.collectRootImports() } +
- listOfNotNull(declaration.asRootType())
- }
-}
-
-private fun KSType.asRootType(): KSDeclaration? {
- return declaration.asRootType()
-}
-
-private fun KSDeclaration.asRootType(): KSDeclaration? {
- return if (this.packageName.asString().isBlank()) this else null
-}
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessor.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessor.kt
deleted file mode 100644
index 05a8e308..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessor.kt
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-@file:Suppress("detekt:all")
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.getDeclaredFunctions
-import com.google.devtools.ksp.getDeclaredProperties
-import com.google.devtools.ksp.processing.Resolver
-import com.google.devtools.ksp.processing.SymbolProcessor
-import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
-import com.google.devtools.ksp.symbol.*
-
-class RPCSymbolProcessor(
- private val env: SymbolProcessorEnvironment
-) : SymbolProcessor {
- private var services: Sequence = emptySequence()
-
- override fun finish() {
- val codegen = RPCClientServiceGenerator(env.codeGenerator)
-
- services.forEach {
- codegen.generate(it)
- }
- }
-
- override fun process(resolver: Resolver): List {
- val context = RPCSymbolProcessorContext(resolver)
-
- services = sequence {
- resolver.getAllFiles().forEach { file ->
- file.declarations.forEach { declaration ->
- if (declaration is KSClassDeclaration && declaration.classKind == ClassKind.INTERFACE && declaration.superTypes.find { it.resolve() == context.rpcType } != null) {
- yield(handleService(declaration, file, context))
- }
- }
- }
- }
-
- return emptyList()
- }
-
- private fun handleService(
- serviceDeclaration: KSClassDeclaration,
- file: KSFile,
- context: RPCSymbolProcessorContext,
- ): RPCServiceDeclaration {
- if (serviceDeclaration.typeParameters.isNotEmpty()) {
- codegenError(serviceDeclaration)
- }
-
- if (serviceDeclaration.modifiers.intersect(DENY_LIST_SERVICE_MODIFIERS).isNotEmpty()) {
- codegenError(serviceDeclaration)
- }
-
- val processedFunctions = serviceDeclaration.getDeclaredFunctions().toList().map {
- handleServiceFunction(it, context)
- }
-
- val processedProperties = serviceDeclaration.getDeclaredProperties().toList().map {
- handleServiceField(it, context)
- }
-
- return RPCServiceDeclaration(
- declaration = serviceDeclaration,
- simpleName = serviceDeclaration.simpleName.asString(),
- fullName = serviceDeclaration.qualifiedName?.asString()
- ?: codegenError(serviceDeclaration),
- packageName = serviceDeclaration.packageName.asString(),
- functions = processedFunctions,
- fields = processedProperties,
- file = file,
- )
- }
-
- private fun handleServiceFunction(
- functionDeclaration: KSFunctionDeclaration,
- context: RPCSymbolProcessorContext,
- ): RPCServiceDeclaration.Function {
- if (functionDeclaration.typeParameters.isNotEmpty()) {
- codegenError(functionDeclaration)
- }
-
- if (functionDeclaration.extensionReceiver != null) {
- codegenError(functionDeclaration)
- }
-
- if (functionDeclaration.modifiers.intersect(DENY_LIST_FUNCTION_MODIFIERS).isNotEmpty()) {
- codegenError(functionDeclaration)
- }
-
- if (!functionDeclaration.modifiers.contains(Modifier.SUSPEND)) {
- codegenError(functionDeclaration)
- }
-
- if (!functionDeclaration.isAbstract) {
- codegenError(functionDeclaration)
- }
-
- val returnType = functionDeclaration.returnType?.resolve()
- ?: codegenError(functionDeclaration)
-
- val name = functionDeclaration.simpleName.getShortName()
-
- if (name.contains("$")) {
- codegenError(functionDeclaration)
- }
-
- return RPCServiceDeclaration.Function(
- name = name,
- argumentTypes = functionDeclaration.parameters.map {
- handleFunctionArgument(
- functionDeclaration,
- it,
- context
- )
- },
- returnType = returnType,
- )
- }
-
- private fun handleFunctionArgument(
- functionDeclaration: KSFunctionDeclaration,
- argument: KSValueParameter,
- context: RPCSymbolProcessorContext,
- ): RPCServiceDeclaration.Function.Argument {
- val type = argument.type.resolve()
-
- return RPCServiceDeclaration.Function.Argument(
- name = argument.name?.getShortName()
- ?: codegenError(functionDeclaration),
- type = type,
- isVararg = argument.isVararg,
- isContextual = type.declaration.flowTypeOrNull(context) != null,
- )
- }
-
- private fun handleServiceField(
- propertyDeclaration: KSPropertyDeclaration,
- context: RPCSymbolProcessorContext
- ): RPCServiceDeclaration.FlowField {
- if (propertyDeclaration.isMutable) {
- codegenError(propertyDeclaration)
- }
-
- if (propertyDeclaration.extensionReceiver != null) {
- codegenError(propertyDeclaration)
- }
-
- val type = propertyDeclaration.type.resolve()
-
- val flowType = type.declaration.flowTypeOrNull(context)
- ?: codegenError(propertyDeclaration)
-
- val isEager = propertyDeclaration.annotations.any { it.annotationType.resolve() == context.rpcEagerProperty }
-
- val name = propertyDeclaration.simpleName.asString()
-
- if (name.contains("$")) {
- codegenError(propertyDeclaration)
- }
-
- return RPCServiceDeclaration.FlowField(name, type, flowType, isEager)
- }
-
- private fun KSDeclaration.flowTypeOrNull(context: RPCSymbolProcessorContext): RPCServiceDeclaration.FlowField.Type? {
- return when (this) {
- context.plainFlowType.declaration -> RPCServiceDeclaration.FlowField.Type.Plain
- context.sharedFlowType.declaration -> RPCServiceDeclaration.FlowField.Type.Shared
- context.stateFlowType.declaration -> RPCServiceDeclaration.FlowField.Type.State
- else -> null
- }
- }
-
- companion object {
- internal val DENY_LIST_SERVICE_MODIFIERS = setOf(
- Modifier.PRIVATE,
- Modifier.SEALED,
- Modifier.INTERNAL,
- Modifier.EXPECT,
- Modifier.ACTUAL,
- Modifier.EXTERNAL
- )
-
- internal val DENY_LIST_FUNCTION_MODIFIERS = setOf(
- Modifier.PRIVATE,
- Modifier.INTERNAL,
- Modifier.INFIX,
- Modifier.OPERATOR,
- Modifier.EXPECT,
- Modifier.ACTUAL,
- Modifier.FINAL,
- Modifier.TAILREC,
- )
- }
-}
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorContext.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorContext.kt
deleted file mode 100644
index ff021dbd..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorContext.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.getClassDeclarationByName
-import com.google.devtools.ksp.processing.Resolver
-import com.google.devtools.ksp.symbol.KSType
-import com.google.devtools.ksp.symbol.KSTypeArgument
-
-class RPCSymbolProcessorContext(private val resolver: Resolver) {
- val rpcType by lazy { resolveClass("kotlinx.rpc.RPC") }
-
- val plainFlowType by lazy { resolveClass("kotlinx.coroutines.flow.Flow") }
-
- val sharedFlowType by lazy { resolveClass("kotlinx.coroutines.flow.SharedFlow") }
-
- val stateFlowType by lazy { resolveClass("kotlinx.coroutines.flow.StateFlow") }
-
- val rpcEagerProperty by lazy { resolveClass("kotlinx.rpc.RPCEagerField") }
-
- private fun resolveClass(name: String, typeArguments: List = emptyList()): KSType {
- return resolver.getClassDeclarationByName(name)?.asType(typeArguments)
- ?: codegenError("Could not find $name declaration")
- }
-}
diff --git a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorProvider.kt b/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorProvider.kt
deleted file mode 100644
index bf749b2f..00000000
--- a/ksp-plugin/src/main/kotlin/kotlinx/rpc/codegen/RPCSymbolProcessorProvider.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.codegen
-
-import com.google.devtools.ksp.processing.SymbolProcessor
-import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
-import com.google.devtools.ksp.processing.SymbolProcessorProvider
-
-class RPCSymbolProcessorProvider : SymbolProcessorProvider {
- override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
- return RPCSymbolProcessor(environment)
- }
-}
diff --git a/ksp-plugin/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/ksp-plugin/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
deleted file mode 100644
index 8a5d6ddb..00000000
--- a/ksp-plugin/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
-#
-
-kotlinx.rpc.codegen.RPCSymbolProcessorProvider
\ No newline at end of file
diff --git a/publishLocal.sh b/publishLocal.sh
index 7e7fdfd8..3355b090 100755
--- a/publishLocal.sh
+++ b/publishLocal.sh
@@ -9,9 +9,3 @@ set -euxo pipefail
./gradlew publishAllPublicationsToBuildRepoRepository
./gradlew -p compiler-plugin publishAllPublicationsToBuildRepoRepository
./gradlew -p gradle-plugin publishAllPublicationsToBuildRepoRepository
-
-if [ -x "./gradlew -p ksp-plugin publishAllPublicationsToBuildRepoRepository" ]; then
- echo "KSP is on"
-else
- echo "KSP is off"
-fi;
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 630fc5a4..775df541 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,10 +1,3 @@
-/*
- * 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.whenKotlinIsAtLeast
-
/*
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
@@ -41,10 +34,6 @@ plugins {
dependencyResolutionManagement {
includeBuild("compiler-plugin")
-
- whenKotlinIsAtLeast(2, 0, 0) otherwise {
- includeBuild("ksp-plugin")
- }
}
includePublic(":bom")
diff --git a/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/AutoCloseable.kt b/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/AutoCloseable.kt
deleted file mode 100644
index 13e60c99..00000000
--- a/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/AutoCloseable.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package kotlinx.rpc.internal.utils
-
-import kotlin.contracts.ExperimentalContracts
-import kotlin.contracts.InvocationKind
-import kotlin.contracts.contract
-
-// copied from stdlib, as there it is available only from Kotlin 1.8
-
-@InternalRPCApi
-interface AutoCloseable {
- fun close()
-}
-
-@InternalRPCApi
-@OptIn(ExperimentalContracts::class)
-@Suppress("detekt.TooGenericExceptionCaught")
-inline fun T.use(block: (T) -> R): R {
- contract {
- callsInPlace(block, InvocationKind.EXACTLY_ONCE)
- }
- var exception: Throwable? = null
- try {
- return block(this)
- } catch (e: Throwable) {
- exception = e
- throw e
- } finally {
- this.closeFinally(exception)
- }
-}
-
-@InternalRPCApi
-@PublishedApi
-@Suppress("detekt.TooGenericExceptionCaught")
-internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when {
- this == null -> {}
- cause == null -> close()
- else ->
- try {
- close()
- } catch (closeException: Throwable) {
- cause.addSuppressed(closeException)
- }
-}
diff --git a/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/hex/HexBytes.kt b/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/hex/HexBytes.kt
index 9ea96a25..fc23ed68 100644
--- a/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/hex/HexBytes.kt
+++ b/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/hex/HexBytes.kt
@@ -6,55 +6,10 @@ package kotlinx.rpc.internal.utils.hex
import kotlinx.rpc.internal.utils.InternalRPCApi
-// Original HexExtensions.kt from stdlib are not available for Kotlin 1.8 and earlier versions
-
-private const val LOWER_CASE_HEX_DIGITS = "0123456789abcdef"
-private const val UPPER_CASE_HEX_DIGITS = "0123456789ABCDEF"
-
-// case-insensitive parsing
-private val HEX_DIGITS_TO_DECIMAL = IntArray(128) { -1 }.apply {
- LOWER_CASE_HEX_DIGITS.forEachIndexed { index, char -> this[char.code] = index }
- UPPER_CASE_HEX_DIGITS.forEachIndexed { index, char -> this[char.code] = index }
-}
-
-@InternalRPCApi
-fun ByteArray.toHexStringInternal(lowercase: Boolean = true): String {
- val digits = if (lowercase) LOWER_CASE_HEX_DIGITS else UPPER_CASE_HEX_DIGITS
-
- return buildString(size * 2) {
- for (element in this@toHexStringInternal) {
- val byte = element.toInt() and 0xFF
-
- append(digits[byte shr 4])
- append(digits[byte and 0xF])
- }
- }
-}
-
-@InternalRPCApi
-fun String.hexToByteArrayInternal(): ByteArray {
- val result = ByteArray(length / 2)
-
- var i = 0
- var byteIndex = 0
- while (i < length) {
- result[byteIndex++] = ((decimalFromHexDigitAt(i++) shl 4) or decimalFromHexDigitAt(i++)).toByte()
- }
-
- return result
-}
-
-private fun String.decimalFromHexDigitAt(index: Int): Int {
- val code = this[index].code
- if (code > 127 || HEX_DIGITS_TO_DECIMAL[code] < 0) {
- throw NumberFormatException("Expected a hexadecimal digit at index $index, but was ${this[index]}")
- }
- return HEX_DIGITS_TO_DECIMAL[code]
-}
-
+@OptIn(ExperimentalStdlibApi::class)
@InternalRPCApi
fun String.hexToReadableBinary(): String {
- return hexToByteArrayInternal().joinToString("") { byte ->
+ return hexToByteArray().joinToString("") { byte ->
byte.toInt().toChar().display()
}
}
diff --git a/versions-root/kotlin-versions-lookup.csv b/versions-root/kotlin-versions-lookup.csv
index 6e326e29..d013683c 100644
--- a/versions-root/kotlin-versions-lookup.csv
+++ b/versions-root/kotlin-versions-lookup.csv
@@ -1,23 +1,5 @@
-Kotlin,ksp,atomicfu,serialization,detekt-gradle-plugin,gradle-kotlin-dsl,binary-compatibility-validator,kover
-2.0.21,0.0.0,0.25.0,1.7.3,1.23.7,5.1.1,0.16.3,0.8.3
-2.0.20,0.0.0,0.25.0,1.7.3,1.23.7,5.1.1,0.16.3,0.8.3
-2.0.10,0.0.0,0.25.0,1.7.1,1.23.7,5.1.1,0.16.3,0.8.3
-2.0.0,0.0.0,0.25.0,1.7.1,1.23.7,5.1.1,0.16.3,0.8.3
-1.9.25,1.0.20,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.24,1.0.20,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.23,1.0.19,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.22,1.0.17,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.21,1.0.16,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.20,1.0.14,0.22.0,1.6.1,1.23.6,4.1.0,0.14.0,0.8.0
-1.9.10,1.0.13,0.22.0,1.6.0,1.23.3,4.1.0,0.14.0,0.8.0
-1.9.0,1.0.13,0.22.0,1.6.0,1.23.1,4.1.0,0.14.0,0.8.0
-1.8.22,1.0.11,0.21.0,1.5.1,1.23.0,4.0.6,0.14.0,0.8.0
-1.8.21,1.0.11,0.21.0,1.5.1,1.23.0,4.0.6,0.14.0,0.8.0
-1.8.20,1.0.11,0.21.0,1.5.0,1.23.0,4.0.6,0.14.0,0.8.0
-1.8.10,1.0.9,0.20.0,1.5.0,1.23.0,4.0.6,0.12.1,0.8.0
-1.8.0,1.0.9,0.20.0,1.4.1,1.23.0,4.0.0,0.12.0,0.8.0
-1.7.22,1.0.8,0.18.5,1.4.1,1.22.0,2.3.3,0.12.0,0.0.0
-1.7.21,1.0.8,0.18.5,1.4.1,1.22.0,2.3.3,0.12.0,0.0.0
-1.7.20,1.0.8,0.18.5,1.4.1,1.22.0,2.3.3,0.12.0,0.0.0
-1.7.10,1.0.6,0.18.0,1.4.0,1.22.0,2.3.3,0.12.0,0.0.0
-1.7.0,1.0.6,0.18.0,1.4.0,1.22.0,2.3.3,0.12.0,0.0.0
+Kotlin,atomicfu,serialization,detekt-gradle-plugin,gradle-kotlin-dsl,binary-compatibility-validator,kover
+2.0.21,0.25.0,1.7.3,1.23.7,5.1.1,0.16.3,0.8.3
+2.0.20,0.25.0,1.7.3,1.23.7,5.1.1,0.16.3,0.8.3
+2.0.10,0.25.0,1.7.1,1.23.7,5.1.1,0.16.3,0.8.3
+2.0.0,0.25.0,1.7.1,1.23.7,5.1.1,0.16.3,0.8.3
diff --git a/versions-root/libs.versions.toml b/versions-root/libs.versions.toml
index a7ea9561..c14b803c 100644
--- a/versions-root/libs.versions.toml
+++ b/versions-root/libs.versions.toml
@@ -26,7 +26,6 @@ kotlinx-browser = "0.1"
# The current version is the one that is used with the latest Kotlin.
#
# NOTE: When updating kotlin-versions-lookup.csv, update the latest version here for the Renovate configs
-ksp = "0.0.0"
atomicfu = "0.25.0"
serialization = "1.7.3"
detekt-gradle-plugin = "1.23.7"
@@ -62,10 +61,6 @@ serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-jso
serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "serialization" }
serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization" }
-# ksp, version will be inherited from kotlin-lang and kotlin-versions-lookup.json lookup table
-ksp-runtime-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
-ksp-gradle-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
-
# ktor
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
@@ -107,11 +102,9 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
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" }
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
-atomicfu-old = { id = "kotlinx-atomicfu", version.ref = "atomicfu" }
-atomicfu-new = { id = "org.jetbrains.kotlinx.atomicfu", version.ref = "atomicfu" }
+atomicfu = { id = "org.jetbrains.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" }
diff --git a/versions-root/targets-since-kotlin-lookup.json b/versions-root/targets-since-kotlin-lookup.json
index c78a27a8..239c0e33 100644
--- a/versions-root/targets-since-kotlin-lookup.json
+++ b/versions-root/targets-since-kotlin-lookup.json
@@ -2,28 +2,28 @@
"jvm": "*",
"js": "*",
- "wasmJs": "2.0.0",
- "wasmWasi": "2.0.0",
+ "wasmJs": "*",
+ "wasmWasi": "*",
"mingwX64": "-",
- "linuxX64": "1.9.10",
- "linuxArm64": "1.9.10",
+ "linuxX64": "*",
+ "linuxArm64": "*",
- "iosX64": "1.9.10",
- "iosArm64": "1.9.10",
- "iosSimulatorArm64": "1.9.10",
+ "iosX64": "*",
+ "iosArm64": "*",
+ "iosSimulatorArm64": "*",
- "watchosX64": "1.9.10",
+ "watchosX64": "*",
"watchosArm32": "-",
- "watchosArm64": "1.9.10",
- "watchosSimulatorArm64": "1.9.10",
+ "watchosArm64": "*",
+ "watchosSimulatorArm64": "*",
"watchosDeviceArm64": "-",
- "tvosX64": "1.9.10",
- "tvosArm64": "1.9.10",
+ "tvosX64": "*",
+ "tvosArm64": "*",
"tvosSimulatorArm64": "-",
- "macosX64": "1.9.10",
- "macosArm64": "1.9.10"
+ "macosX64": "*",
+ "macosArm64": "*"
}