galax-io / sbt-schema-registry-plugin   0.6.1

Apache License 2.0 GitHub

Sbt plugin for download schemas from schema registry. This plugin adds a new task `schemaRegistryDownload` for downloading schemas and some configuration parameters to declare schemas and schema registry endpoint

Scala versions: 2.12
sbt plugins: 1.x

CI Maven Central License Scala Steward badge

SBT Schema Registry Plugin

SBT plugin for downloading Avro schemas from a Confluent Schema Registry. Adds a schemaRegistryDownload task and configuration settings to declare which schemas to fetch.

Installation

Add the following to your project/plugins.sbt:

resolvers ++= Seq(
  "Confluent" at "https://packages.confluent.io/maven/",
)

addSbtPlugin("org.galaxio" % "sbt-schema-registry-plugin" % "<plugin-version>")

Configuration

In your build.sbt:

import org.galaxio.avro.{RegistrySubject, SchemaRegistryAuth}

val schemas = Seq(
  RegistrySubject("hello.world.schema", 2),      // specific version
  RegistrySubject("schema1-name", 12),            // specific version
  RegistrySubject.latest("schema2-name"),          // latest version
)

lazy val root = (project in file("."))
  .settings(
    schemaRegistryUrl      := "http://schema-registry-host:8081",
    schemaRegistrySubjects ++= schemas,
  )

Authentication

schemaRegistryAuth := Some(SchemaRegistryAuth.BasicAuth("username", "password"))

Extra Properties

Pass any Confluent client properties (SSL, timeouts, etc.):

schemaRegistryProperties := Map(
  "schema.registry.ssl.truststore.location" -> "/path/to/truststore.jks",
  "schema.registry.ssl.truststore.password" -> "changeit",
)

Usage

Download all schemas listed in schemaRegistrySubjects:

sbt "Compile / schemaRegistryDownload"

Schema files are saved as <subject>-<version>.avsc in the target folder. The build will fail if any schema download fails.

Settings

Parameter Description Default
schemaRegistrySubjects List of schema subjects with versions Seq()
schemaRegistryUrl URL of the schema registry http://localhost:8081
schemaRegistryTargetFolder Output directory for downloaded schemas src/main/avro
schemaRegistryCacheSize Schema registry client cache size 200
schemaRegistryAuth Authentication credentials None
schemaRegistryProperties Additional schema registry client config Map.empty

License

Apache 2.0