HunterEl / rules_avro

πŸƒ bazel rules for generating code from avro schemas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bazel avro rules

Build Status

Bazel rules for generating java sources and libraries from avro schemas

Rules

Getting started

To use the Avro rules, add the following to your projects WORKSPACE file

# rules_avro depends on rules_jvm_external: https://github.com/bazelbuild/rules_jvm_external
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "2.7"

RULES_JVM_EXTERNAL_SHA = "f04b1466a00a2845106801e0c5cec96841f49ea4e7d1df88dc8e4bf31523df74"

http_archive(
    name = "rules_jvm_external",
    sha256 = RULES_JVM_EXTERNAL_SHA,
    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)


rules_avro_version="c9bfdda9e909e4213abc595a07353e0d23128bbd" # update this commit hash as needed

git_repository(
    name = "io_bazel_rules_avro",
    commit = rules_avro_version,
    remote = "git@github.com:meetup/rules_avro.git",
)

load("@io_bazel_rules_avro//avro:avro.bzl", "avro_repositories")
avro_repositories()
# or specify a version
avro_repositories(version = "1.9.1")

Then in your BUILD file, just add the following so the rules will be available:

load("@io_bazel_rules_avro//avro:avro.bzl", "avro_gen", "avro_java_library")

avro_gen

avro_gen(name, srcs, strings, encoding)

Generates .srcjar containing generated .java source files from a collection of .avsc schemas

Attributes
name Name, required

A unique name for this rule.

srcs List of labels, required

List of .avsc files used as inputs for code generation

strings Boolean, optional

use java.lang.String instead of Utf8.

encoding String, optional

set the encoding of output files.

avro_java_library

avro_java_library(name, srcs, strings, encoding)

Same as above except that the outputs include those provided by java_library rules.

Meetup 2017

About

πŸƒ bazel rules for generating code from avro schemas

License:MIT License


Languages

Language:Starlark 86.7%Language:Shell 12.4%Language:Makefile 0.9%