Bazel rules for avro and open api

520 views
Skip to first unread message

Doug Tangren

unread,
May 18, 2017, 1:00:43 AM5/18/17
to bazel-discuss
I wanted to share some work my company open sourced as well as gather some feedback on design as we're new to bazel and aren't sure we're using idiomatic patterns. We're in the process of moving away from sbt towards bazel and are trying to fill in some gaps where we previously relies on sbt plugins.

https://github.com/meetup/rules_avro generates java src jars and libraries from avro schemas

https://github.com/meetup/rules_openapi uses swagger codegen to generate arbitrary code from open api specs. We use this to generate scala micro service clients. These get packaged into src jars but I realize this could be useful for and languages swagger codegen supports that are also supported by bazel. What I'm unsure of yet is what the output format would look like for those languages. What are other folks doing for src outputs for non jvm languages?

Marcel Hlopko

unread,
May 24, 2017, 4:14:21 AM5/24/17
to Doug Tangren, bazel-discuss, ca...@google.com, dsl...@google.com
Hi Doug!

Cool stuff that you're working on!

Reg. outputs for different languages, I think principled solution is to use aspects to produce just the right output depending on which language is used. Adding +Carmi Grushko who did this for proto rules, and +Dmitry Lomov who is our cool ideas (such as aspects) generator :)

Thanks for open-sourcing your rules!

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/de0b7d64-38d4-4b6c-85b3-5b1fb099d0df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

Carmi Grushko

unread,
May 24, 2017, 10:09:39 AM5/24/17
to Marcel Hlopko, Doug Tangren, bazel-discuss, dsl...@google.com
For reference, https://bazel.build/blog/2017/02/27/protocol-buffers.html describes proto support - namely that we have a proto_library rule which provides structure to .proto files, and $LANG_proto_library rules per each concrete language we generate code for.

On Wed, May 24, 2017 at 4:14 AM, Marcel Hlopko <hlo...@google.com> wrote:
Hi Doug!

Cool stuff that you're working on!

Reg. outputs for different languages, I think principled solution is to use aspects to produce just the right output depending on which language is used. Adding +Carmi Grushko who did this for proto rules, and +Dmitry Lomov who is our cool ideas (such as aspects) generator :)

Thanks for open-sourcing your rules!

On Thu, May 18, 2017 at 7:00 AM Doug Tangren <d.ta...@gmail.com> wrote:
I wanted to share some work my company open sourced as well as gather some feedback on design as we're new to bazel and aren't sure we're using idiomatic patterns. We're in the process of moving away from sbt towards bazel and are trying to fill in some gaps where we previously relies on sbt plugins.

https://github.com/meetup/rules_avro generates java src jars and libraries from avro schemas

https://github.com/meetup/rules_openapi uses swagger codegen to generate arbitrary code from open api specs. We use this to generate scala micro service clients. These get packaged into src jars but I realize this could be useful for and languages swagger codegen supports that are also supported by bazel. What I'm unsure of yet is what the output format would look like for those languages. What are other folks doing for src outputs for non jvm languages?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

Doug Tangren

unread,
May 24, 2017, 11:11:23 AM5/24/17
to Carmi Grushko, Marcel Hlopko, bazel-discuss, dsl...@google.com
On Wed, May 24, 2017 at 10:09 AM, Carmi Grushko <ca...@google.com> wrote:
For reference, https://bazel.build/blog/2017/02/27/protocol-buffers.html describes proto support - namely that we have a proto_library rule which provides structure to .proto files, and $LANG_proto_library rules per each concrete language we generate code for.

Cool. I'll have to take a look. 

I'm relying on swagger codegen as the engine that does language specifics. 

I'm mainly interested in what the kinds of packaging non jvm languages typically use for outputs in bazel. With java/scala, you can use .srcjars as outputs which can be used as inputs for {java,scala}_libraries. I'm not sure what that looks like for other languages. swagger codegen supports many additional not jvm languages so I wast sure what an appropriate packaging would look like for those. Im mainly using this for custom swagger codegen that generates scala but I'm interested in broadening support for non jvm folks that use openapi for describing their services.

Of note, some of those languages do not generate the identical outputs given the same inputs which doesn't play well with bazel caching :/ The typical case is a template will add a generated at timestamp :shakesfist: thankfully some built in templates to generate consistent outputs given the same inputs  https://github.com/meetup/rules_openapi/blob/master/test.sh#L35-L43 
Reply all
Reply to author
Forward
0 new messages