From 1c84aed172ba46bce81cc5cce2bc15995f0fb934 Mon Sep 17 00:00:00 2001
From: Alexander Sysoev
- Artifacts for gRPC integration are published separately
+ Artifacts for gRPC integration are published separately
and updated frequently, independent of the main releases.
@@ -39,137 +44,425 @@
Here
- gRPC requires additional code generation from the protoc
- compiler.
- It is set up automatically for you when the
- We provide additional options for configuration:
+ The minimum required configuration looks like this:
- You can still use
+ All source sets are generated automatically and available
+ via the
+ By default, four source directories will be generated:
+
+ To generate code, we need to use protoc plugins.
+ By default, we use the following plugins:
+
+ You can configure the plugins in the
- The minimum recommended configuration looks like this:
+
+ Every plugin is a
- By default, four source sets will be generated:
+ Buf's plugin configuration
+ options:
- Only the declarations from the
- Source sets are generated into the
+ To make UX smooth, we introduce a concept of a generated workspace.
+ It's a directory that contains all the necessary files for Buf to work:
+
+ This workspace is created automatically for each source set,
+ and can be found in the
+ We create the following tasks if the project is configured to use
+ To configure Buf, use the
+ General configuration options:
+
+
+ We only support
+ To create a custom task, it must be a subclass of the
+ Registering the task can be done in two ways:
+ A workspace task (recommended):
+ These tasks can be executed on a generated workspace for all proto source sets.
+ A regular task:
+ It is just a regular Gradle task that has access to the Buf's executable
+ and some predefined properties.
+
The minimum required configuration looks like this:
@@ -79,36 +79,24 @@
}
- This will enable the code generation for your
@@ -133,30 +121,44 @@
}
- By default, four source directories will be generated:
+ By default, the following source directories are generated:
+ Source set hierarchy is not supported, and we have no plans to support it.
+ That means, for example,
+ that you can't have
- To generate code, we need to use protoc plugins.
+ To generate code, we use
@@ -195,17 +197,17 @@
- Every plugin is a build.gradle.kts
:
<version>
comes from the badge above.Kotlin/JVM
projects.
- com.google.protobuf
Gradle Plugin
+ in projects with our plugin to prevent conflicts.
+ com.google.protobuf
- plugin is present in the project.
- .proto
files
+ protobuf
extension to access the configuration.
- The following is the equivalent for the above code using the protobuf
extension:
+ This will enable the code generation for your .proto
files.
+ We create special source sets for .proto
files:
+
+
+ main
and test
- source sets for Kotlin/JVM projects.
+ Default source directories are src/main/proto
and src/test/proto
.
+ jvmMain
and jvmTest
- source sets for Kotlin/Multiplatform projects.
+ Default source directories are src/jsmMain/proto
and src/jvmTest/proto
.
+ src/commonMain/proto
and src/commonTest/proto
in the
+ future.
+ jsMain
and jsTest
source sets for proto files.
+ Same for native and WASM.
+ Proto files can only be in the jvmMain
and jvmTest
source sets.
+ (Later to be replaced with commonMain
and commonTest
)
+
+
+ If you have a use case for other source sets and a hierarchy,
+ please report it.
+ protoSourceSets
Gradle Project extension:
+
+ java
- protobuf Java declarations, attached to java
sources
+ grpc-java
- gRPC Java declarations, attached to java
sources
+ grpc-kotlin
- gRPC Kotlin wrappers for Java, attached to kotlin
sources
+ kotlinx-multiplatform
- our wrappers for all of the above, attached to kotlin
sources
+ kotlinx-multiplatform
source set are intended to be used.
+ The other ones are for internal use only and will be removed in the future.
+
+
+ kotlinx-multiplatform
- out own protoc plugin.
+ rpc
block:
+ protocPlugins
is a NamedDomainObjectContainer<ProtocPlugin>
,
+ which allows to add your own plugins.
+ ProtocPlugin
class, that can be configured like this:
-
java
- protobuf Java declarationsgrpc
- gRPC Java declarationsgrpckt
- gRPC Kotlin wrappers for Javakotlinx-rpc
- our wrappers for all of the aboveAll
or Directory
+ true
or false
+ true
or false
+ kotlinx-rpc
source set are intended to be used.
+ A plugin, once added to the protocPlugins
container, can be used in a source set:
$BUILD_DIR/generated/source/proto/main
directory
- unless specified otherwise.
+ As you may already notice,
+ we use Buf —
+ a tool for managing and building Protobuf schemas.
+ We use its CLI to execute tasks like code generation.
build.buf
Gradle Plugin
+ and prohibit using it in projects with our plugin to prevent conflicts.
+
+
+ .proto
files
+ buf.yaml
file
+ buf.gen.yaml
file
+ main
source set to a test
source set,
+ making imports intuitive.
+ build/protoBuild
directory.
+ You don't need to do anything with it, unless you want to customise it.
+ grpc
:
+
+
+ generateBufYaml<sourceSet>
+ — generates buf.yaml
+
+
+ Type: kotlinx.rpc.buf.tasks.GenerateBufYaml
+ generateBufGenYaml<sourceSet>
+ — generates buf.gen.yaml
+
+
+ Type: kotlinx.rpc.buf.tasks.GenerateBufGenYaml
+ processProtoFiles<sourceSet>
+ — copies proto files to the workspace directory
+
+
+ Type: kotlinx.rpc.proto.ProcessProtoFiles
+ processProtoFilesImport<sourceSet>
+ — copies import proto files to the workspace directory
+
+
+ Type: kotlinx.rpc.proto.ProcessProtoFiles
+ bufGenerate<sourceSet>
+ — runs buf generate
command.
+
+
+ Type: kotlinx.rpc.buf.tasks.BufGenerateTask
+ buf
block:
+
+
+ Text
, Color
, Json
or Default
+ buf
commands, always converted to whole seconds
+ --debug
enables Buf's --debug
option.
+ buf generate
configuration options:
+
+
+ true
or false
+ true
or false
+ Text
, Json
, Msvs
,
+ Junit
, GithubActions
or Default
+ generate
tasks for now.
+ But Buf has great capabilities for managing .proto
files,
+ like linting, detection of breaking changes, etc.
+ So we made it possible to create custom buf tasks.
+ kotlinx.rpc.buf.tasks.BufExecTask
.
+ It doesn't need to define a @TaskAction
, just a set of arguments and a command to execute.
+
+
+ .proto
files
+ Working with proto-files
.proto
files.
- We create special source sets for .proto
files:
+ This enables code generation for your
main
and test
- source sets for Kotlin/JVM projects.
- Default source directories are src/main/proto
and src/test/proto
.
+ Default source directories are jvmMain
and jvmTest
- source sets for Kotlin/Multiplatform projects.
- Default source directories are src/jsmMain/proto
and src/jvmTest/proto
.
+ Default source directories are src/commonMain/proto
and src/commonTest/proto
in the
+ These will change to jsMain
and jsTest
source sets for proto files.
- Same for native and WASM.
- Proto files can only be in the jvmMain
and jvmTest
source sets.
- (Later to be replaced with commonMain
and commonTest
)
-
-
- If you have a use case for other source sets and a hierarchy,
- please report it.
-
java
- protobuf Java declarations, attached to java
sources
+ java
- protobuf Java declarations, attached to java
sources.
grpc-java
- gRPC Java declarations, attached to java
sources
+ grpc-java
- gRPC Java declarations, attached to java
sources.
grpc-kotlin
- gRPC Kotlin wrappers for Java, attached to kotlin
sources
+ grpc-kotlin
- gRPC Kotlin wrappers for Java, attached to kotlin
sources.
kotlinx-multiplatform
- our wrappers for all of the above, attached to kotlin
sources
+ kotlin-multiplatform
- wrappers for all of the above, attached to kotlin
sources.
kotlinx-multiplatform
source set are intended to be used.
- The other ones are for internal use only and will be removed in the future.
+ Only the declarations from the kotlin-multiplatform
source set are intended to be used.
+ The others are for internal use only and will be removed in a future release.
jsMain
and jsTest
source sets for proto files.
+ The same applies for native and Wasm targets.
+ Currently, jvmMain
and jvmTest
source sets.
+ (Later to be replaced with commonMain
and commonTest
)
+
+
+ If you have a use case for other source sets and a hierarchy,
+ please report it.
+
@@ -172,7 +174,7 @@
plugin.
kotlinx-multiplatform
- out own protoc plugin.
+ kotlin-multiplatform
- out own protoc plugin.
protocPlugins
is a NamedDomainObjectContainer<ProtocPlugin>
,
- which allows to add your own plugins.
+ which allows you to add your own plugins.
ProtocPlugin
class, that can be configured like this:
+ Each plugin is represented by a ProtocPlugin
and can be configured like this:
All
or Directory
- true
or false
- true
or false
-
- A plugin, once added to the protocPlugins
container, can be used in a source set:
+ Once a plugin is added to the protocPlugins
container, it can be used in a source set:
build.buf
Gradle Plugin
- and prohibit using it in projects with our plugin to prevent conflicts.
+ and disallow using it in projects that apply our plugin, in order to avoid conflicts.
- To make UX smooth, we introduce a concept of a generated workspace. + To improve the developer experience, we introduce the concept of a generated workspace. It's a directory that contains all the necessary files for Buf to work:
.proto
files
+ Filtered buf.yaml
file
+ Generated buf.gen.yaml
file
+ Generated main
source set to a test
source set,
@@ -306,26 +308,26 @@
- This workspace is created automatically for each source set,
- and can be found in the build/protoBuild
directory.
+ This workspace is created automatically for each source set
+ and can be found in the
- We create the following tasks if the project is configured to use grpc
:
+ If your project is configured to use gRPC, the following tasks will be generated:
generateBufYaml<sourceSet>
- — generates buf.yaml
+ — generates kotlinx.rpc.buf.tasks.GenerateBufYaml
generateBufGenYaml<sourceSet>
- — generates buf.gen.yaml
+ — generates kotlinx.rpc.buf.tasks.GenerateBufGenYaml
@@ -359,12 +361,12 @@
rpc {
grpc {
buf {
- // configure Buf here
+ // Configure Buf
logFormat = BufExtenstion.LogFormat.Text
timeout = 60.seconds
generate {
- // configure Buf generate here
+ // Configure Buf generate
includeImports = false
includeWkt = false
@@ -377,51 +379,51 @@
General configuration options:
-Text
, Color
, Json
or Default
- buf
commands, always converted to whole seconds
- --debug
enables Buf's --debug
option.
- --debug
enables Buf's --debug
option as well.
+
buf generate
configuration options:
true
or false
- true
or false
- Text
, Json
, Msvs
,
Junit
, GithubActions
or Default
-
- We only support generate
tasks for now.
- But Buf has great capabilities for managing .proto
files,
- like linting, detection of breaking changes, etc.
- So we made it possible to create custom buf tasks.
+ Currently, we only support generate
tasks.
+ However, because of Buf's capabilities for managing
- To create a custom task, it must be a subclass of the kotlinx.rpc.buf.tasks.BufExecTask
.
- It doesn't need to define a @TaskAction
, just a set of arguments and a command to execute.
+ To create a custom task, extend the kotlinx.rpc.buf.tasks.BufExecTask
class.
+ You don't need to define a @TaskAction
; just a set of arguments and a command to execute.
- Registering the task can be done in two ways: + You can register the task in two ways:
- It is just a regular Gradle task that has access to the Buf's executable + It is a standard Gradle task that has access to the Buf's executable and some predefined properties.
From c9951053921b22ce71896eb6197cdd352b044304 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev
This workspace is created automatically for each source set
and can be found in the