xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

Kotlin Support #45

Open bcmedeiros opened 5 years ago

bcmedeiros commented 5 years ago

I'd like to be able to compile my templates directly to Kotlin, rather than use Java code mixed with Kotlin classes.

We may be able to use some support implemented in https://grpc.io/blog/kotlin-gradle-projects to achieve that.

sergei-ivanov commented 5 years ago

I read that blog post and also checked out their release notes and the associated PRs. As far as I can tell, neither protoc nor grpc plugin generate Kotlin sources directly. Neither do they have protobuf/grpc runtime libraries written in Kotlin (again, AFAIK). I think the only thing they have done is a more seamless integration of protobuf-gradle-plugin with Kotlin build lifecycle in gradle.

To summarise, support for generation of Kotlin classes should be first implemented in Protobuf/gRPC. Feel free to vote for this feature request: protocolbuffers/protobuf#3742

K1ngjulien commented 2 years ago

@sergei-ivanov

protoc now natively supports generating a kotlin DSL on top of the java builders. Unfortunately I've yet to figure out if its possible to use your plugin for this...

According to This guide it should be possible with a plugin, yet I get the following error:

The parameters 'pluginId' for goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom are missing or invalid

It seems to me that because "kotlin" is now a built in plugin, the pluginId is rejected, or am I misunderstanding something completely?

It would be great to see some better documentation about this :sweat_smile:

liyunchou commented 2 years ago

I meet the same problem when compile proto in java project, but also using the protobuf-maven-pligin. It turns out that my pom file is set to packaging in pom form, which should be jar from. I solved my problem after change the packaging type.

pom
<packaging>jar</packaging>