|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!DOCTYPE topic |
| 3 | + SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd"> |
| 4 | +<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 5 | + xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd" |
| 6 | + title="Configuration" id="grpc-configuration"> |
| 7 | + |
| 8 | + <tldr> |
| 9 | + <p> |
| 10 | + Artifacts for gRPC integration are published <a href="https://public.jetbrains.space/p/krpc/packages/maven/grpc">separately</a> |
| 11 | + and updated frequently, independent of the main releases. |
| 12 | + </p> |
| 13 | + <p> |
| 14 | + <a href="https://maven.pkg.jetbrains.space/public/p/krpc/grpc"> |
| 15 | + <img alt="Latest dev version" |
| 16 | + src="https://img.shields.io/badge/dynamic/xml?url=https%3A%2F%2Fmaven.pkg.jetbrains.space%2Fpublic%2Fp%2Fkrpc%2Fgrpc%2Forg%2Fjetbrains%2Fkotlinx%2Fkotlinx-rpc-core%2Fmaven-metadata.xml&query=%2F%2Fmetadata%2Fversioning%2Flatest&label=Latest%20dev%20version&color=forest-green&cacheSeconds=60"/> |
| 17 | + </a> |
| 18 | + </p> |
| 19 | + </tldr> |
| 20 | + |
| 21 | + <p> |
| 22 | + <a href="https://grpc.io">gRPC</a> integration is available in an experimental state. |
| 23 | + The artifacts are published separately in our <a |
| 24 | + href="https://public.jetbrains.space/p/krpc/packages/maven/grpc">Space repository</a>. |
| 25 | + </p> |
| 26 | + <chapter title="Dependencies configuration" id="dependencies-configuration"> |
| 27 | + <p>Below is an example of a project setup.</p> |
| 28 | + <code>settings.gradle.kts</code>: |
| 29 | + <code-block lang="Kotlin"> |
| 30 | + pluginManagement { |
| 31 | + repositories { |
| 32 | + gradlePluginPortal() |
| 33 | + mavenCentral() |
| 34 | + maven("https://maven.pkg.jetbrains.space/public/p/krpc/grpc") |
| 35 | + } |
| 36 | + } |
| 37 | + </code-block> |
| 38 | + <p> |
| 39 | + <code>build.gradle.kts</code>: |
| 40 | + </p> |
| 41 | + <code-block lang="Kotlin"> |
| 42 | + plugins { |
| 43 | + kotlin("jvm") version "2.1.0" |
| 44 | + kotlin("plugin.serialization") version "2.1.0" |
| 45 | + id("org.jetbrains.kotlinx.rpc.plugin") version "<version>" |
| 46 | + id("com.google.protobuf") version "0.9.4" |
| 47 | + } |
| 48 | + |
| 49 | + repositories { |
| 50 | + mavenCentral() |
| 51 | + maven("https://maven.pkg.jetbrains.space/public/p/krpc/grpc") |
| 52 | + } |
| 53 | + |
| 54 | + dependencies { |
| 55 | + implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:<version>") |
| 56 | + implementation("ch.qos.logback:logback-classic:1.5.16") |
| 57 | + implementation("io.grpc:grpc-netty:1.69.0") |
| 58 | + } |
| 59 | + </code-block> |
| 60 | + <p>Here <code><version></code> comes from the badge above.</p> |
| 61 | + <warning> |
| 62 | + The setup has only been tested on <code>Kotlin/JVM</code> projects. |
| 63 | + </warning> |
| 64 | + </chapter> |
| 65 | + <chapter title="Protoc setup" id="protoc-setup"> |
| 66 | + <p> |
| 67 | + gRPC requires additional code generation from the <a href="https://github.com/google/protobuf-gradle-plugin">protoc</a> |
| 68 | + compiler. |
| 69 | + This can be setup up in the following way: |
| 70 | + </p> |
| 71 | + <code-block lang="Kotlin"> |
| 72 | + protobuf { |
| 73 | + protoc { |
| 74 | + artifact = "com.google.protobuf:protoc:4.29.3" |
| 75 | + } |
| 76 | + |
| 77 | + plugins { |
| 78 | + create("kotlinx-rpc") { |
| 79 | + artifact = "org.jetbrains.kotlinx:kotlinx-rpc-protobuf-plugin:<version>:all@jar" |
| 80 | + } |
| 81 | + |
| 82 | + create("grpc") { |
| 83 | + artifact = "io.grpc:protoc-gen-grpc-java:1.69.0" |
| 84 | + } |
| 85 | + |
| 86 | + create("grpckt") { |
| 87 | + artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + generateProtoTasks { |
| 92 | + all().all { |
| 93 | + plugins { |
| 94 | + create("kotlinx-rpc") { |
| 95 | + option("debugOutput=protobuf-plugin.log") |
| 96 | + option("messageMode=interface") |
| 97 | + } |
| 98 | + create("grpc") |
| 99 | + create("grpckt") |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + </code-block> |
| 105 | + <list> |
| 106 | + <li> |
| 107 | + Four source sets will be generated: |
| 108 | + <list> |
| 109 | + <li><code>java</code> - protobuf Java declarations</li> |
| 110 | + <li><code>grpc</code> - gRPC Java declarations</li> |
| 111 | + <li><code>grpckt</code> - gRPC Kotlin wrappers for Java</li> |
| 112 | + <li><code>kotlinx-rpc</code> - pur wrappers for all of the above</li> |
| 113 | + </list> |
| 114 | + <p> |
| 115 | + You won't need to use the first three directly, only the declarations from the <code>kotlinx-rpc</code> |
| 116 | + source set are intended to be used. |
| 117 | + </p> |
| 118 | + Source sets are generated into <code>$BUILD_DIR/generated/source/proto/main</code> directory |
| 119 | + unless specified otherwise. |
| 120 | + </li> |
| 121 | + <li> |
| 122 | + <code>option("debugOutput=protobuf-plugin.log")</code> lets you specify the file |
| 123 | + for the <code>protoc</code> plugin debug output. |
| 124 | + </li> |
| 125 | + <li> |
| 126 | + <code>option("messageMode=interface")</code> is intended to be like so. Don't change it. |
| 127 | + </li> |
| 128 | + </list> |
| 129 | + </chapter> |
| 130 | +</topic> |
0 commit comments