Closed ktoso closed 6 years ago
Is ScalaPB a plain protoc plugin in the end, so that we can use it for generation of the data classes for scaladsl?
Yes, we can use it like that. I think it also provides a binary, but we'll likely want to not use the binary but ship with the code and configure gradle / maven to call our runnables (as we want to set settings perhaps).
The snippet to run it is pretty much as simple as:
// this actually is code from protoc-sbt:
override def run(req: Array[Byte]): Array[Byte] = {
val registry = ExtensionRegistry.newInstance()
Scalapb.registerAllExtensions(registry)
val request = CodeGeneratorRequest.parseFrom(req, registry) // <<< raw protoc plugin proto types
ProtobufGenerator.handleCodeGeneratorRequest(request).toByteArray
}
where input is to be obtained from stdin and output is sent to stdout == this is a "normal protoc plugin" then.
Thanks for clarifying, soo many tools
This'll need a diagram, I'm sure ;-)
protobuf-gradle-plugin invokes protoc
so we'd want to have a custom plugin that uses protoc-jar (like sbt-protoc does). Looks like building a gradle plugin from an sbt project is cumbersome, so perhaps this should be a separate project - but perhaps let's put it into the akka-grpc repo for convenience for now anyway.
Hmmm... alternatively we could contribute this capability, it's been requested in the main plugin https://github.com/google/protobuf-gradle-plugin/issues/168 , my thought is that staying close to "what people use" may be beneficial..
Though if that's too hard (let's skim and see if it would be very hard, I can code groovy (did in the past...) if no one else wants to ;-)).
Otherwise the custom gradle plugin sounds good; Keeping it here in this repo sounds good too :)
We might not need to move to proto-jar
, https://github.com/google/protobuf-gradle-plugin#pre-compiled-protoc-artifacts looks sufficient.
Constrained this issue to Java projects, split off Gradle support for Scala projects to #42
Status: all the pieces are in place so this works by plugging into the Google protobuf plugin (see plugin-tester-java), but it'd still be nice to have our own plugin for a readily-configured out-of-the-box experience
As long as we have a plain protoc plugin we should be able to integrate with gradle nicely as well:
https://github.com/google/protobuf-gradle-plugin
Note that that's the official google gradle plugin