admin管理员组

文章数量:1244331

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: .gradle.kts

My Question:

  1. Is it possible to configure the build script to generate only Kotlin code (both for gRPC stubs and Protobuf messages) without relying on any Java-generated classes?
  2. If yes, what changes should I make to my build.gradle.kts file to achieve this?

I'd also like to know more about what's going on in the protobuf {} block in my build.grdle.kts

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/grpc/grpc-kotlin/blob/master/examples/stub-android/build.gradle.kts

My Question:

  1. Is it possible to configure the build script to generate only Kotlin code (both for gRPC stubs and Protobuf messages) without relying on any Java-generated classes?
  2. If yes, what changes should I make to my build.gradle.kts file to achieve this?

I'd also like to know more about what's going on in the protobuf {} block in my build.grdle.kts

Share Improve this question asked Feb 16 at 13:58 ramzes1_1ramzes1_1 796 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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.

本文标签: