akka / akka-grpc

A platform to build and run apps that are elastic, agile, and resilient. SDK, libraries, and hosted environments.
https://doc.akka.io/libraries/akka-grpc/current/
Other
431 stars 124 forks source link

Standalone compiler #656

Closed Marcus-Rosti closed 4 years ago

Marcus-Rosti commented 5 years ago

Short description

There should be a way to run the compiler in some standalone fashion. I've been trying to move our services to a monorepo built with bazel but there doesn't appear to be a way to standalone compile the protos to the akka-grpc style code.

Details

Build an executable jar and CLI for the akka-grpc scalapb compiler

raboof commented 5 years ago

Thanks for the feature request!

We might be pretty close to this, since we're already packaging up the code generation into jars with a main class to be used from the Gradle plugin:

So it might be that all that's needed is to package those up a bit nicer and provide documentation on how to use them.

I'd be interested to hear how this goes!

Marcus-Rosti commented 5 years ago

I tried a good deal today to get the gradle plugin to be more executable friendly. But I nobly failed. I may just have to table this (my) project until y'all can do that! I'll keep watching the PRs!

raboof commented 5 years ago

Is there anything in particular you were having a hard time with? I'd be happy to try and give some more pointers.

raboof commented 5 years ago

I think both akka-grpc-codegen and akka-grpc-scalapb-protoc-plugin expect a CodeGeneratorRequest object on stdin (serialized with protobuf).

I'm not too familiar with Bazel, but I could imagine you could try:

Marcus-Rosti commented 5 years ago

SO looks like it's pretty hard to get protoc to generate that intermediate form CodeGeneratorRequest just via the command line. It's does that via the plugin field for protoc a la scalapb: https://scalapb.github.io/scalapbc.html#using-scalapb-as-a-proper-protoc-plugin and https://github.com/scalapb/ScalaPB/blob/master/build.sbt#L302-L336

I think I'll have to package the codegen package here similarly.

raboof commented 5 years ago

I think I'll have to package the codegen package here similarly.

You should be able to use the codegen assembly jar (e.g. https://repo1.maven.org/maven2/com/lightbend/akka/grpc/akka-grpc-codegen_2.12/0.7.1/akka-grpc-codegen_2.12-0.7.1-assembly.jar) in this way I think.

Marcus-Rosti commented 4 years ago

I got this all to work! Thanks

jsbrucker commented 4 years ago

@ Marcus-Rosti I'm just starting to investigate using Bazel would it be possible for you to post a link to a repo that shows an example of what you did?

Update: https://github.com/akka/akka-grpc/issues/744#issuecomment-566580088