Simple Avrohugger

Extremely simplified version of Julian Peeters's sbt-avrohugger that doesn't make any assumptions.

Right now only supports generating specific records.

Installation

Add this to plugins.sbt (uses Avrohugger 0.18):

addSbtPlugin("com.mariussoutier.sbt" % "sbt-simple-avrohugger" % "0.9.7")

Usage

First, enable the plugin on the project you want to use it with.

import com.mariussoutier.sbt.AvroGeneratorKeys.Avro
lazy val root = project(...)
  .enablePlugins(com.mariussoutier.sbt.AvroGenerator)
  .settings(
    sourceDirectory in Avro := target.value / "avro"
  )

Then use generateSpecific by adding it to a generator, for example:

import com.mariussoutier.sbt.AvroGeneratorKeys
sourceGenerators in Compile += AvroGeneratorKeys.generateSpecific

To chain it with other plugins, e.g. my sbt-unpack plugin, do this:

import com.mariussoutier.sbt.UnpackKeys
import com.mariussoutier.sbt.AvroGeneratorKeys
sourceGenerators in Compile += Def.sequential(UnpackKeys.unpackJars, AvroGeneratorKeys.generateSpecific)

Filter files by using sbt's include or exclude filter.

import com.mariussoutier.sbt.AvroGeneratorKeys.Avro
includeFilter in Avro := "*.avdl" | "*.avsc"