sbt plugin for generating the Java sources for Apache Avro schemas and protocols.
Switch branches/tags
Nothing to show
Clone or download
alde and nevillelyh Specify UTF-8 as encoding when reading source file (#55)
Relying on the default charset should be avoided as it varies based on
locale/collation. Setting it to UTF-8 should be generally safe, as files
saved with ASCII or ISO-8859-1 encoding will still open correctly.

Without it, an environment such as the Google cloud-builer for sbt will
error out if the file is saved as UTF-8.
Latest commit 5bec5c0 Jun 13, 2018




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


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:

addSbtPlugin("com.cavorite" % "sbt-avro-1-8" % "1.1.4")


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


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.8.2 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.


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:

(stringType in AvroConfig) := "String"


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


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


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.