diff --git a/docs/pages/kotlinx-rpc/topics/grpc-configuration.topic b/docs/pages/kotlinx-rpc/topics/grpc-configuration.topic index 5ac509320..aba2cfd52 100644 --- a/docs/pages/kotlinx-rpc/topics/grpc-configuration.topic +++ b/docs/pages/kotlinx-rpc/topics/grpc-configuration.topic @@ -40,8 +40,8 @@

plugins { - kotlin("jvm") version "2.1.0" - kotlin("plugin.serialization") version "2.1.0" + kotlin("jvm") version "%kotlin-version%" + kotlin("plugin.serialization") version "%kotlin-version%" id("org.jetbrains.kotlinx.rpc.plugin") version "<version>" id("com.google.protobuf") version "0.9.4" } @@ -66,65 +66,110 @@

gRPC requires additional code generation from the protoc compiler. - This can be setup up in the following way: + It is set up automatically for you when the com.google.protobuf + plugin is present in the project. +

+

+ We provide additional options for configuration:

- protobuf { - protoc { - artifact = "com.google.protobuf:protoc:4.29.3" - } + rpc { + grpc { + // Enforce additional checks on the project configuration + enabled = true - plugins { - create("kotlinx-rpc") { - artifact = "org.jetbrains.kotlinx:kotlinx-rpc-protobuf-plugin:<version>:all@jar" + // Quick access to a `Locator` and `Options` + // for the kotlinx-rpc Protobuf plugin + plugin { + options { + // Add or modify options + option("debugOutput=myFile.txt") + } + + locator { + // Override artifact coordinates + artifact = "some-other:artifact:version" + } } - create("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:1.69.0" + // same as `plugin`, but for gRPC Java generation + grpcJavaPlugin { ... } + // same as `plugin`, but for gRPC Kotlin generation + grpcKotlinPlugin { ... } + + // access `generateProto` tasks + tasks { + plugins { + create("python") + } } - create("grpckt") { - artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" + // access `generateProto` tasks with a filter + tasksMatching { it.isTest }.all { + plugins { + create("cpp") + } + } + } + } + +

+ You can still use protobuf extension to access the configuration. + The following is the equivalent for the above code using the protobuf extension: +

+ + protobuf { + plugins { + named(GrpcExtension.LOCATOR_NAME) { + artifact = "some-other:artifact:version" } + + named(GrpcExtension.GRPC_JAVA_LOCATOR_NAME) { ... } + named(GrpcExtension.GRPC_KOTLIN_LOCATOR_NAME) { ... } } generateProtoTasks { all().all { plugins { - create("kotlinx-rpc") { - option("debugOutput=protobuf-plugin.log") - option("messageMode=interface") + named(GrpcExtension.LOCATOR_NAME) { + option("debugOutput=myFile.txt") + } + + create("python") + + if (isTest) { + create("cpp") } - create("grpc") - create("grpckt") } } } } +

+ The minimum recommended configuration looks like this: +

+ + rpc { + grpc { + enabled = true + } + } + +

+ By default, four source sets will be generated: +

-
  • - Four source sets will be generated: - -
  • java - protobuf Java declarations
  • -
  • grpc - gRPC Java declarations
  • -
  • grpckt - gRPC Kotlin wrappers for Java
  • -
  • kotlinx-rpc - pur wrappers for all of the above
  • -
    -

    - You won't need to use the first three directly, only the declarations from the kotlinx-rpc - source set are intended to be used. -

    - Source sets are generated into $BUILD_DIR/generated/source/proto/main directory - unless specified otherwise. - -
  • - option("debugOutput=protobuf-plugin.log") lets you specify the file - for the protoc plugin debug output. -
  • -
  • - option("messageMode=interface") is intended to be like so. Don't change it. -
  • +
  • java - protobuf Java declarations
  • +
  • grpc - gRPC Java declarations
  • +
  • grpckt - gRPC Kotlin wrappers for Java
  • +
  • kotlinx-rpc - our wrappers for all of the above
  • +

    + Only the declarations from the kotlinx-rpc source set are intended to be used. +

    +

    + Source sets are generated into the $BUILD_DIR/generated/source/proto/main directory + unless specified otherwise. +

    diff --git a/samples/grpc-app/build.gradle.kts b/samples/grpc-app/build.gradle.kts index 9fbfd78cd..4d9f4d488 100644 --- a/samples/grpc-app/build.gradle.kts +++ b/samples/grpc-app/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin("jvm") version "2.1.10" kotlin("plugin.serialization") version "2.1.10" - id("org.jetbrains.kotlinx.rpc.plugin") version "0.5.0-grpc-6" + id("org.jetbrains.kotlinx.rpc.plugin") version "0.5.1-grpc-16" id("com.google.protobuf") version "0.9.4" } @@ -22,42 +22,13 @@ kotlin { } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.5.0-grpc-6") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.5.1-grpc-16") implementation("ch.qos.logback:logback-classic:1.5.16") implementation("io.grpc:grpc-netty:1.69.0") } -val buildDirPath: String = project.layout.buildDirectory.get().asFile.absolutePath - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:4.29.3" - } - - plugins { - create("kotlinx-rpc") { - artifact = "org.jetbrains.kotlinx:kotlinx-rpc-protobuf-plugin:0.5.0-grpc-6:all@jar" - } - - create("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:1.69.0" - } - - create("grpckt") { - artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" - } - } - - generateProtoTasks { - all().all { - plugins { - create("kotlinx-rpc") { - option("debugOutput=$buildDirPath/protobuf-plugin.log") - option("messageMode=interface") - } - create("grpc") - create("grpckt") - } - } +rpc { + grpc { + enabled = true } }