From 9909c294e04b9a84c9516dcfd7fdba10992069a4 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Tue, 11 Feb 2025 19:13:23 +0100 Subject: [PATCH 1/2] Simplified grpc gradle config --- gradle-plugin/build.gradle.kts | 29 +- .../src/main/kotlin/kotlinx/rpc/Extensions.kt | 15 +- .../main/kotlin/kotlinx/rpc/GrpcExtension.kt | 262 ++++++++++++++++++ .../kotlin/kotlinx/rpc/RpcGradlePlugin.kt | 4 +- protobuf-plugin/build.gradle.kts | 35 +-- versions-root/libs.versions.toml | 1 + 6 files changed, 311 insertions(+), 35 deletions(-) create mode 100644 gradle-plugin/src/main/kotlin/kotlinx/rpc/GrpcExtension.kt diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts index 61ec1f9fb..e51c187f9 100644 --- a/gradle-plugin/build.gradle.kts +++ b/gradle-plugin/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 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 @@ -20,6 +20,7 @@ kotlin { } dependencies { + implementation(libs.protobuf.gradle.plugin) compileOnly(libs.kotlin.gradle.plugin) } @@ -46,18 +47,28 @@ gradlePlugin { } abstract class GeneratePluginVersionTask @Inject constructor( - @get:Input val pluginVersion: String, + @get:Input val libraryVersion: String, + @get:Input val protobufVersion: String, + @get:Input val grpcVersion: String, + @get:Input val grpcKotlinVersion: String, @get:OutputDirectory val sourcesDir: File ) : DefaultTask() { @TaskAction fun generate() { - val sourceFile = File(sourcesDir, "PluginVersion.kt") + val sourceFile = File(sourcesDir, "Versions.kt") sourceFile.writeText( """ package kotlinx.rpc - const val PLUGIN_VERSION = "$pluginVersion" + const val LIBRARY_VERSION = "$libraryVersion" + + @Deprecated("Use kotlinx.rpc.LIBRARY_VERSION instead", ReplaceWith("kotlinx.rpc.LIBRARY_VERSION")) + const val PLUGIN_VERSION = LIBRARY_VERSION + + const val PROTOBUF_VERSION = "$protobufVersion" + const val GRPC_VERSION = "$grpcVersion" + const val GRPC_KOTLIN_VERSION = "$grpcKotlinVersion" """.trimIndent() ) @@ -66,8 +77,14 @@ abstract class GeneratePluginVersionTask @Inject constructor( val sourcesDir = File(project.layout.buildDirectory.asFile.get(), "generated-sources/pluginVersion") -val generatePluginVersionTask = - tasks.register("generatePluginVersion", version.toString(), sourcesDir) +val generatePluginVersionTask = tasks.register( + "generatePluginVersion", + version.toString(), + libs.versions.protobuf.asProvider().get().toString(), + libs.versions.grpc.asProvider().get().toString(), + libs.versions.grpc.kotlin.get().toString(), + sourcesDir, +) kotlin { sourceSets { diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt index eaf6dbf37..9c0c2e1c8 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ @file:Suppress("unused") @@ -7,12 +7,16 @@ package kotlinx.rpc import org.gradle.api.Action +import org.gradle.api.Project import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property +import org.gradle.kotlin.dsl.findByType import org.gradle.kotlin.dsl.newInstance import org.gradle.kotlin.dsl.property import javax.inject.Inject +fun Project.rpcExtension(): RpcExtension = extensions.findByType() ?: RpcExtension(objects) + open class RpcExtension @Inject constructor(objects: ObjectFactory) { /** * Controls `@Rpc` [annotation type-safety](https://github.com/Kotlin/kotlinx-rpc/pull/240) compile-time checkers. @@ -36,6 +40,15 @@ open class RpcExtension @Inject constructor(objects: ObjectFactory) { fun strict(configure: Action) { configure.execute(strict) } + + /** + * Grpc settings. + */ + val grpc: GrpcExtension = objects.newInstance() + + fun grpc(configure: Action) { + configure.execute(grpc) + } } open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/GrpcExtension.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/GrpcExtension.kt new file mode 100644 index 000000000..74aa42cb6 --- /dev/null +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/GrpcExtension.kt @@ -0,0 +1,262 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.rpc + +import com.google.protobuf.gradle.ExecutableLocator +import com.google.protobuf.gradle.GenerateProtoTask +import com.google.protobuf.gradle.ProtobufExtension +import org.gradle.api.Action +import org.gradle.api.GradleException +import org.gradle.api.Project +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property +import org.gradle.api.specs.Spec +import org.gradle.api.tasks.TaskCollection +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.property +import org.gradle.kotlin.dsl.the +import javax.inject.Inject + +public open class GrpcExtension @Inject constructor(objects: ObjectFactory, private val project: Project) { + /** + * Determines whether the gRPC support is enabled in the project. + * + * Allows for additional configuration checks. + */ + public val enabled: Property = objects.property().convention(false) + + /** + * Access for [GrpcPlugin] for [LOCATOR_NAME] name. + */ + public fun plugin(action: Action) { + pluginAccess(action, LOCATOR_NAME) + } + + /** + * Access for [GrpcPlugin] for [GRPC_JAVA_LOCATOR_NAME] name. + */ + public fun grpcJavaPlugin(action: Action) { + pluginAccess(action, GRPC_JAVA_LOCATOR_NAME) + } + + /** + * Access for [GrpcPlugin] for [GRPC_KOTLIN_LOCATOR_NAME] name. + */ + public fun grpcKotlinPlugin(action: Action) { + pluginAccess(action, GRPC_KOTLIN_LOCATOR_NAME) + } + + /** + * Shortcut for + * + * ```kotlin + * protobuf { + * generateProtoTasks.all().all { ... } + * } + * ``` + */ + public fun tasks(taskAction: Action) { + project.the().generateProtoTasks.all().all(taskAction) + } + + /** + * Shortcut for + * + * ```kotlin + * protobuf { + * generateProtoTasks.all().matching { ... } + * } + * ``` + */ + public fun tasksMatching(spec: Spec): TaskCollection { + return project.the().generateProtoTasks.all().matching(spec) + } + + private fun pluginAccess(action: Action, locatorName: String) { + val extension = project.the() + val plugin = object : GrpcPlugin { + override fun options(options: Action) { + extension.generateProtoTasks.all().all { + options.execute(plugins.maybeCreate(locatorName)) + } + } + + override fun locator(locatorAction: Action) { + extension.plugins { + locatorAction.execute(maybeCreate(locatorName)) + } + } + } + + action.execute(plugin) + } + + public companion object { + /** + * [com.google.protobuf.gradle.ExecutableLocator]'s name for the `kotlinx-rpc` plugin + * + * ```kotlin + * protobuf { + * plugins { + * named(LOCATOR_NAME) + * } + * } + * ``` + * + * Same name is used for [GenerateProtoTask] plugin in `generateProtoTasks.plugins` + */ + public const val LOCATOR_NAME: String = "kotlinx-rpc" + + /** + * [com.google.protobuf.gradle.ExecutableLocator]'s name for the `grpc-java` plugin + * + * ```kotlin + * protobuf { + * plugins { + * named(GRPC_JAVA_LOCATOR_NAME) + * } + * } + * ``` + * + * Same name is used for [GenerateProtoTask] plugin in `generateProtoTasks.plugins` + */ + public const val GRPC_JAVA_LOCATOR_NAME: String = "grpc" + + /** + * [com.google.protobuf.gradle.ExecutableLocator]'s name for the `grpc-kotlin` plugin + * + * ```kotlin + * protobuf { + * plugins { + * named(GRPC_KOTLIN_LOCATOR_NAME) + * } + * } + * ``` + * + * Same name is used for [GenerateProtoTask] plugin in `generateProtoTasks.plugins` + */ + public const val GRPC_KOTLIN_LOCATOR_NAME: String = "grpckt" + } +} + +/** + * Access to a specific protobuf plugin. + */ +public interface GrpcPlugin { + /** + * Access for [GenerateProtoTask.PluginOptions] + * + * ```kotlin + * rpc { + * grpc { + * plugin { + * options { + * option("option=value") + * } + * } + * } + * } + * ``` + */ + public fun options(optionsAction: Action) + + /** + * Access for [ExecutableLocator] + * + * ```kotlin + * rpc { + * grpc { + * plugin { + * locator { + * path = "$buildDirPath/libs/protobuf-plugin-$version-all.jar" + * } + * } + * } + * } + * ``` + */ + public fun locator(locatorAction: Action) +} + +internal fun Project.configureGrpc() { + val grpc = rpcExtension().grpc + var wasApplied = false + + pluginManager.withPlugin("com.google.protobuf") { + if (wasApplied) { + return@withPlugin + } + + wasApplied = true + + val protobuf = extensions.findByType() + ?: run { + logger.error("Protobuf plugin (com.google.protobuf) was not applied. Please report of this issue.") + return@withPlugin + } + + protobuf.configureProtobuf(project = project) + } + + afterEvaluate { + if (grpc.enabled.get() && !wasApplied) { + throw GradleException( + """ + gRPC Support is enabled, but 'com.google.protobuf' was not be applied during project evaluation. + The 'com.google.protobuf' plugin must be applied to the project first. + """.trimIndent() + ) + } + } +} + +private fun ProtobufExtension.configureProtobuf(project: Project) { + val buildDirPath: String = project.layout.buildDirectory.get().asFile.absolutePath + + protoc { + artifact = "com.google.protobuf:protoc:$PROTOBUF_VERSION" + } + + plugins { + val existed = findByName(GrpcExtension.LOCATOR_NAME) != null + maybeCreate(GrpcExtension.LOCATOR_NAME).apply { + if (!existed) { + artifact = "org.jetbrains.kotlinx:kotlinx-rpc-protobuf-plugin:$LIBRARY_VERSION:all@jar" + } + } + + val grpcJavaPluginExisted = findByName(GrpcExtension.GRPC_JAVA_LOCATOR_NAME) != null + maybeCreate(GrpcExtension.GRPC_JAVA_LOCATOR_NAME).apply { + if (!grpcJavaPluginExisted) { + artifact = "io.grpc:protoc-gen-grpc-java:$GRPC_VERSION" + } + } + + val grpcKotlinPluginExisted = findByName(GrpcExtension.GRPC_KOTLIN_LOCATOR_NAME) != null + maybeCreate(GrpcExtension.GRPC_KOTLIN_LOCATOR_NAME).apply { + if (!grpcKotlinPluginExisted) { + artifact = "io.grpc:protoc-gen-grpc-kotlin:$GRPC_KOTLIN_VERSION:jdk8@jar" + } + } + } + + generateProtoTasks { + all().all { + plugins { + val existed = findByName(GrpcExtension.LOCATOR_NAME) != null + maybeCreate(GrpcExtension.LOCATOR_NAME).apply { + if (!existed) { + option("debugOutput=$buildDirPath/protobuf-plugin.log") + option("messageMode=interface") + } + } + + maybeCreate(GrpcExtension.GRPC_JAVA_LOCATOR_NAME) + + maybeCreate(GrpcExtension.GRPC_KOTLIN_LOCATOR_NAME) + } + } + } +} diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt index 96ccff1a1..90ab03cd9 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc @@ -14,6 +14,8 @@ class RpcGradlePlugin : Plugin { target.extensions.create("rpc") applyCompilerPlugin(target) + + target.configureGrpc() } private fun applyCompilerPlugin(target: Project) { diff --git a/protobuf-plugin/build.gradle.kts b/protobuf-plugin/build.gradle.kts index a0a75d847..657170006 100644 --- a/protobuf-plugin/build.gradle.kts +++ b/protobuf-plugin/build.gradle.kts @@ -67,36 +67,17 @@ tasks.jar { val buildDirPath: String = project.layout.buildDirectory.get().asFile.absolutePath -protobuf { - protoc { - artifact = libs.protoc.get().toString() - } - - plugins { - create("kotlinx-rpc") { - path = "$buildDirPath/libs/protobuf-plugin-$version-all.jar" - } - - create("grpc") { - artifact = libs.grpc.protoc.gen.java.get().toString() - } +rpc { + grpc { + enabled = true - create("grpckt") { - artifact = libs.grpc.protoc.gen.kotlin.get().toString() + ":jdk8@jar" - } - } - - generateProtoTasks { - all().matching { it.isTest }.all { - plugins { - create("kotlinx-rpc") { - option("debugOutput=$buildDirPath/protobuf-plugin.log") - option("messageMode=interface") - } - create("grpc") - create("grpckt") + plugin { + locator { + path = "$buildDirPath/libs/protobuf-plugin-$version-all.jar" } + } + tasksMatching { it.isTest }.all { dependsOn(tasks.jar) } } diff --git a/versions-root/libs.versions.toml b/versions-root/libs.versions.toml index a1a338569..5c855cf19 100644 --- a/versions-root/libs.versions.toml +++ b/versions-root/libs.versions.toml @@ -96,6 +96,7 @@ protoc = { module = "com.google.protobuf:protoc", version.ref = "protobuf" } protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" } protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" } protobuf-kotlin = { module = "com.google.protobuf:protobuf-kotlin", version.ref = "protobuf" } +protobuf-gradle-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "protobuf-gradle" } grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" } grpc-util = { module = "io.grpc:grpc-util", version.ref = "grpc" } grpc-netty = { module = "io.grpc:grpc-netty", version.ref = "grpc" } From cde17ab7b56151ca5a8f3c5b3f674bb3d3d5c874 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Thu, 13 Feb 2025 13:30:53 +0100 Subject: [PATCH 2/2] Enabled explicit API for the Gradle Plugin --- gradle-plugin/build.gradle.kts | 12 +++--- .../src/main/kotlin/kotlinx/rpc/Extensions.kt | 37 +++++++++++-------- .../rpc/KotlinCompilerPluginBuilder.kt | 6 +-- .../kotlin/kotlinx/rpc/RpcDangerousApi.kt | 4 +- .../kotlin/kotlinx/rpc/RpcGradlePlugin.kt | 2 +- .../main/kotlin/kotlinx/rpc/RpcPluginConst.kt | 6 +-- .../kotlin/kotlinx/rpc/compilerPlugins.kt | 10 ++--- 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts index e51c187f9..f2106c2ad 100644 --- a/gradle-plugin/build.gradle.kts +++ b/gradle-plugin/build.gradle.kts @@ -16,7 +16,7 @@ group = "org.jetbrains.kotlinx" version = rootProject.libs.versions.kotlinx.rpc.get() kotlin { - explicitApi = ExplicitApiMode.Disabled + explicitApi = ExplicitApiMode.Strict } dependencies { @@ -61,14 +61,14 @@ abstract class GeneratePluginVersionTask @Inject constructor( """ package kotlinx.rpc - const val LIBRARY_VERSION = "$libraryVersion" + public const val LIBRARY_VERSION: String = "$libraryVersion" @Deprecated("Use kotlinx.rpc.LIBRARY_VERSION instead", ReplaceWith("kotlinx.rpc.LIBRARY_VERSION")) - const val PLUGIN_VERSION = LIBRARY_VERSION + public const val PLUGIN_VERSION: String = LIBRARY_VERSION - const val PROTOBUF_VERSION = "$protobufVersion" - const val GRPC_VERSION = "$grpcVersion" - const val GRPC_KOTLIN_VERSION = "$grpcKotlinVersion" + public const val PROTOBUF_VERSION: String = "$protobufVersion" + public const val GRPC_VERSION: String = "$grpcVersion" + public const val GRPC_KOTLIN_VERSION: String = "$grpcKotlinVersion" """.trimIndent() ) diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt index 9c0c2e1c8..aad5fe777 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/Extensions.kt @@ -15,9 +15,9 @@ import org.gradle.kotlin.dsl.newInstance import org.gradle.kotlin.dsl.property import javax.inject.Inject -fun Project.rpcExtension(): RpcExtension = extensions.findByType() ?: RpcExtension(objects) +public fun Project.rpcExtension(): RpcExtension = extensions.findByType() ?: RpcExtension(objects) -open class RpcExtension @Inject constructor(objects: ObjectFactory) { +public open class RpcExtension @Inject constructor(objects: ObjectFactory) { /** * Controls `@Rpc` [annotation type-safety](https://github.com/Kotlin/kotlinx-rpc/pull/240) compile-time checkers. * @@ -25,40 +25,43 @@ open class RpcExtension @Inject constructor(objects: ObjectFactory) { * This option is only needed to prevent cases where type-safety analysis fails and valid code can't be compiled. */ @RpcDangerousApi - val annotationTypeSafetyEnabled = objects.property().convention(true) + public val annotationTypeSafetyEnabled: Property = objects.property().convention(true) /** * Strict mode settings. * Allows configuring the reporting state of deprecated features. */ - val strict: RpcStrictModeExtension = objects.newInstance() + public val strict: RpcStrictModeExtension = objects.newInstance() /** * Strict mode settings. * Allows configuring the reporting state of deprecated features. */ - fun strict(configure: Action) { + public fun strict(configure: Action) { configure.execute(strict) } /** * Grpc settings. */ - val grpc: GrpcExtension = objects.newInstance() + public val grpc: GrpcExtension = objects.newInstance() - fun grpc(configure: Action) { + /** + * Grpc settings. + */ + public fun grpc(configure: Action) { configure.execute(grpc) } } -open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { +public open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { /** * `StateFlow`s in RPC services are deprecated, * due to their error-prone nature. * * Consider using plain flows and converting them to state on the application side. */ - val stateFlow: Property = objects.strictModeProperty() + public val stateFlow: Property = objects.strictModeProperty() /** * `SharedFlow`s in RPC services are deprecated, @@ -66,7 +69,7 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { * * Consider using plain flows and converting them to state on the application side. */ - val sharedFlow: Property = objects.strictModeProperty() + public val sharedFlow: Property = objects.strictModeProperty() /** * Nested flows in RPC services are deprecated, @@ -74,7 +77,7 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { * * Consider using plain flows and converting them to state on the application side. */ - val nestedFlow: Property = objects.strictModeProperty() + public val nestedFlow: Property = objects.strictModeProperty() /** * WIP: https://youtrack.jetbrains.com/issue/KRPC-133 @@ -93,7 +96,7 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { * * Consider returning a Flow and requesting other data in a different method. */ - val notTopLevelServerFlow: Property = objects.strictModeProperty() + public val notTopLevelServerFlow: Property = objects.strictModeProperty() /** * Fields in RPC services are deprecated, @@ -101,7 +104,7 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { * * Consider using regular streaming. */ - val fields: Property = objects.strictModeProperty() + public val fields: Property = objects.strictModeProperty() private fun ObjectFactory.strictModeProperty( default: RpcStrictMode = RpcStrictMode.WARNING, @@ -110,8 +113,12 @@ open class RpcStrictModeExtension @Inject constructor(objects: ObjectFactory) { } } -enum class RpcStrictMode { +/** + * Strict mode inspections levels. + * Correspond to same compiler levels of messages. + */ +public enum class RpcStrictMode { NONE, WARNING, ERROR; - fun toCompilerArg(): String = name.lowercase() + internal fun toCompilerArg(): String = name.lowercase() } diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/KotlinCompilerPluginBuilder.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/KotlinCompilerPluginBuilder.kt index b723c82ac..7eb88f03e 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/KotlinCompilerPluginBuilder.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/KotlinCompilerPluginBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact import org.jetbrains.kotlin.gradle.plugin.SubpluginOption -class KotlinCompilerPluginBuilder { +internal class KotlinCompilerPluginBuilder { var applicable : (kotlinCompilation: KotlinCompilation<*>) -> Boolean = { true } var applyToCompilation: (kotlinCompilation: KotlinCompilation<*>) -> Provider> = { it.target.project.provider { emptyList() } @@ -64,6 +64,6 @@ class KotlinCompilerPluginBuilder { } } -fun compilerPlugin(builder: KotlinCompilerPluginBuilder.() -> Unit = {}): KotlinCompilerPluginSupportPlugin { +internal fun compilerPlugin(builder: KotlinCompilerPluginBuilder.() -> Unit = {}): KotlinCompilerPluginSupportPlugin { return KotlinCompilerPluginBuilder().apply(builder).build() } diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcDangerousApi.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcDangerousApi.kt index 17efa87e3..2426ddec5 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcDangerousApi.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcDangerousApi.kt @@ -1,8 +1,8 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc @RequiresOptIn("This API is dangerous. It is not recommended to use it, unless you know what you are doing.") -annotation class RpcDangerousApi +public annotation class RpcDangerousApi diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt index 90ab03cd9..ff83bc2fa 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt @@ -9,7 +9,7 @@ import org.gradle.api.Project import org.gradle.kotlin.dsl.create @Suppress("unused") -class RpcGradlePlugin : Plugin { +public class RpcGradlePlugin : Plugin { override fun apply(target: Project) { target.extensions.create("rpc") diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcPluginConst.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcPluginConst.kt index 387d021b2..2e60c9309 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcPluginConst.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcPluginConst.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.rpc @@ -9,7 +9,7 @@ import org.gradle.api.Project import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import org.jetbrains.kotlin.gradle.utils.loadPropertyFromResources -object RpcPluginConst { +internal object RpcPluginConst { const val GROUP_ID = "org.jetbrains.kotlinx" const val PLUGIN_ID = "kotlinx-rpc" const val COMPILER_PLUGIN_ARTIFACT_ID = "kotlinx-rpc-compiler-plugin" @@ -31,7 +31,7 @@ object RpcPluginConst { } } -val Project.isInternalDevelopment: Boolean +internal val Project.isInternalDevelopment: Boolean get() { return (properties.getOrDefault(INTERNAL_DEVELOPMENT_PROPERTY, null) as String?) ?.toBoolean() ?: false diff --git a/gradle-plugin/src/main/kotlin/kotlinx/rpc/compilerPlugins.kt b/gradle-plugin/src/main/kotlin/kotlinx/rpc/compilerPlugins.kt index 9f3d38522..119bd478d 100644 --- a/gradle-plugin/src/main/kotlin/kotlinx/rpc/compilerPlugins.kt +++ b/gradle-plugin/src/main/kotlin/kotlinx/rpc/compilerPlugins.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ @file:Suppress("detekt.ClassNaming", "ClassName") @@ -10,19 +10,19 @@ import org.gradle.kotlin.dsl.findByType import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin import org.jetbrains.kotlin.gradle.plugin.SubpluginOption -class CompilerPluginK2 : KotlinCompilerPluginSupportPlugin by compilerPlugin({ +internal class CompilerPluginK2 : KotlinCompilerPluginSupportPlugin by compilerPlugin({ pluginSuffix = "-k2" }) -class CompilerPluginCommon : KotlinCompilerPluginSupportPlugin by compilerPlugin({ +internal class CompilerPluginCommon : KotlinCompilerPluginSupportPlugin by compilerPlugin({ pluginSuffix = "-common" }) -class CompilerPluginBackend : KotlinCompilerPluginSupportPlugin by compilerPlugin({ +internal class CompilerPluginBackend : KotlinCompilerPluginSupportPlugin by compilerPlugin({ pluginSuffix = "-backend" }) -class CompilerPluginCli : KotlinCompilerPluginSupportPlugin by compilerPlugin({ +internal class CompilerPluginCli : KotlinCompilerPluginSupportPlugin by compilerPlugin({ pluginSuffix = "-cli" applyToCompilation = {