Giter Club home page Giter Club logo

rules_avro's Introduction

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 = "4.1"
RULES_JVM_EXTERNAL_SHA = "f36441aa876c4f6427bfb2d1f2d723b48e9d930b62662bf723ddfb8fc80f0140"

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 = "96670d5c4a0a3e0f25f4177336e1fa94eba8be5a"
RULES_AVRO_SHA256 = "3bd69872ec72904e843762f7b3532fd1125215503a635a24f6c8037c75b299bc"

http_archive(
    name = "io_bazel_rules_avro",
    strip_prefix = "rules_avro-%s" % RULES_AVRO_VERSION,
    url = "https://github.com/chenrui333/rules_avro/archive/%s.tar.gz" % RULES_AVRO_VERSION,
    sha256 = RULES_AVRO_SHA256
)

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_tools Label, optional

Label to the runnable Avro tools jar. Default, uses the tools jar associated with the downloaded avro version via `avro_repository`

avro_java_library

avro_java_library(name, srcs, strings, encoding)

Same as above except

  • instead of avro_tools, provide avro_libs as a dict(core, tools) of Labels for the avro libraries.
    • See tests for an example the re-uses the downloaded library explicitly
  • the outputs include those provided by java_library rules.

rules_avro's People

Contributors

softprops avatar chenrui333 avatar renovate[bot] avatar austince avatar jyates avatar manuelnaranjo avatar nvachhar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.