I am developing an Android application that uses gRPC for communication with a backend service. Currently, my build script generates both Java and Kotlin code from .proto
files using the protoc-gen-grpc-java
and protoc-gen-grpc-kotlin
plugins. However, I would like to avoid generating any Java code and instead generate only pure Kotlin code for both gRPC stubs and Protobuf messages.
I'm using the build.gradle.kts configuration from the gRPC example: https://github.com/grpc/grpc-kotlin/blob/master/examples/stub-android/build.gradle.kts
My Question:
I'd also like to know more about what's going on in the protobuf {}
block in my build.grdle.kts
I would like to avoid generating any Java code and instead generate only pure Kotlin code for both gRPC stubs and Protobuf messages.
That does not appear to be an option right now. Quoting the documentation:
Note: The Kotlin protoc plugin uses the Java protoc plugin behind the scenes to generate message types as Java classes. Generation of Kotlin sources for proto messages is being discussed in protocolbuffers/protobuf#3742.
You might wish to consider Wire as an alternative.