Skip to content
forked from sbt/sbt-avro

sbt plugin for compiling Avro schemas, similar to sbt-protobuf

License

Notifications You must be signed in to change notification settings

brianmowen/sbt-avro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-avro

https://travis-ci.org/sbt/sbt-avro.svg?branch=master

Overview

sbt-avro is a sbt plugin for generating the Java sources for Avro schemas and protocols. It tries to be clever in compiling schemas with referenced types before dependent ones.

Usage

Install the plugin

Add the plugin according to the sbt documentation.

For instance, add the following lines to the file project/plugins.sbt in your project directory:

// for Avro 1.9.x
addSbtPlugin("com.cavorite" % "sbt-avro-1-9" % "1.1.7")
// for Avro 1.8.x
addSbtPlugin("com.cavorite" % "sbt-avro-1-8" % "1.1.7")

Scope

All settings and tasks are in the avro scope. If you want to execute the generate task directly, just run avro:generate.

Settings

Name Name in shell Default Description
sourceDirectory source-directory src/main/avro Path containing *.avsc, *.avdl and *.avpr files.
javaSource java-source $sourceManaged/compiled_avro Path for the generated *.java files.
version version 1.9.0 Version of the Avro library should be used. A dependency to "org.apache.avro" % "avro-compiler" % "$version" is automatically added to libraryDependencies.
stringType string-type CharSequence Java type for string elements. Possible values: CharSequence (by default), Utf8 and String.
useNamespace use-namespace false Validate that directory layout reflects namespaces, i.e. src/main/avro/com/myorg/MyRecord.avsc.

Example

For example, if you want to change the Java type of the string elements in the schema, you can add the following lines to your build.sbt file:

AvroConfig / stringType := "String"

Tasks

Name Name in shell Description
generate generate Compiles the Avro files. This task is automatically executed every time the project is compiled.

License

This program is distributed under the BSD license. See the file LICENSE for more details.

Credits

sbt-avro is maintained by the sbt Community. The initial code was based on a similar plugin: sbt-protobuf. Feel free to send your comments and bug reports.

Contributors

About

sbt plugin for compiling Avro schemas, similar to sbt-protobuf

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 67.0%
  • Java 33.0%