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:
- 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?
- 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:
- 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?
- 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
1 Answer
Reset to default 2I 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.
本文标签:
版权声明:本文标题:How to generate only Kotlin code (gRPC stubs and Protobuf messages) for an Android application using gRPC? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740204675a2240854.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论