Reputation: 1234
I was thinking about writing a code generator to generate scala from google protobuf definitions file. The reason I see it valuable is the java bindings are too Java-ish and one could do much better in scala. For example for the following definition
message Foo {
required int F1 = 1;
repeated string F2 = 2;
message Inner (
required int F3 = 1;
)
}
I want to be able to construct the proto object from Scala like this:
val foo = Foo (
F1(127),
F2("first", "second"),
Inner (
F3(911)
)
)
My question is if anyone knows something along these lines already existing, or if not do you find it worthy to start a new project?
Upvotes: 18
Views: 7547
Reputation: 26589
There's this project that uses Simple-Build-Tool plugins to achieve that effect: http://github.com/codahale/protobuf-sbt?locale=sv
Update: The above project no longer exists. The sbt-protobuf plugin extended the functionality of that original project. Note, however, that sbt-protobuf generates Java classes, not Scala.
Upvotes: 1
Reputation: 8996
A really good tool to generate both Scala and Java classes from .proto files is ScalaPB. The tool extends the functionality of the sbt-protobuf plugin.
Upvotes: 1
Reputation: 313
I'm currently working on a Scala Protocol Buffers compiler with my mentor Viktor Klang. It's my Google Summer of Code project and you can follow the progress on github at https://github.com/SandroGrzicic/ScalaBuff.
[Update] The main part is complete; I still need to implement Extensions, Groups and field Options support. It's usable and I invite everyone to try it and give feedback; I'm open to suggestions and feature requests.
Upvotes: 14
Reputation: 76
I just came across these but can not vouch for them as I've never used them.
http://code.google.com/p/protobuf-scala/
https://github.com/jeffplaisance/scala-protobuf
Upvotes: 1
Reputation: 1154
Maybe it would be possible to write a Scala compiler plugin that read and compiled .proto files?
Upvotes: 0