Skip to content

Commit

Permalink
fix sourceDirectories and use avroGenerate/target (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevillelyh authored May 1, 2020
1 parent f886e57 commit c4ed8ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ libraryDependencies += "org.apache.avro" % "avro" % "1.9.2"
| Name | Default | Description |
|:-------------------------------|:----------------------------------|:------------|
| `avroSource` | `sourceDirectory` / `avro` | Source directory with `*.avsc`, `*.avdl` and `*.avpr` files. |
| `avroGeneratedSource` | `sourceManaged` / `compiled_avro` | Source directory for generated `.java` files. |
| `avroGenerated / target` | `sourceManaged` / `compiled_avro` | Source directory for generated `.java` files. |
| `avroStringType` | `CharSequence` | Type for representing strings. Possible values: `CharSequence`, `String`, `Utf8`. |
| `avroUseNamespace` | `false` | Validate that directory layout reflects namespaces, i.e. `src/main/avro/com/myorg/MyRecord.avsc`. |
| `avroFieldVisibility` | `public_deprecated` | Field Visibility for the properties. Possible values: `private`, `public`, `public_deprecated`. |
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/sbtavro/SbtAvro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ object SbtAvro extends AutoPlugin {
val avroFieldVisibility = settingKey[String]("Field visibility for the properties. Possible values: private, public, public_deprecated. Default: public_deprecated.")
val avroUseNamespace = settingKey[Boolean]("Validate that directory layout reflects namespaces, i.e. src/main/avro/com/myorg/MyRecord.avsc.")
val avroSource = settingKey[File]("Default Avro source directory.")
val avroGeneratedSource = settingKey[File]("Default Avro generated source directory.")

val avroGenerate = taskKey[Seq[File]]("Generate Java sources for Avro schemas.")

// settings to be applied for both Compile and Test
lazy val configScopedSettings: Seq[Setting[_]] = Seq(
avroSource := sourceDirectory.value / "avro",
avroGeneratedSource := sourceManaged.value / "compiled_avro",
avroGenerate / target := sourceManaged.value / "compiled_avro",
sourceDirectories += (avroGenerate / target).value,

// source generation
avroGenerate := sourceGeneratorTask(avroGenerate).value,
Expand Down Expand Up @@ -135,7 +135,7 @@ object SbtAvro extends AutoPlugin {
private def sourceGeneratorTask(key: TaskKey[Seq[File]]) = Def.task {
val out = (key / streams).value
val srcDir = (key / avroSource).value
val outDir = (key / avroGeneratedSource).value
val outDir = (key / avroGenerate / target).value
val strType = avroStringType.value
val fieldVis = avroFieldVisibility.value
val enbDecimal = avroEnableDecimalLogicalType.value
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-avro/settings/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ libraryDependencies ++= Seq(
avroStringType := "String"
avroFieldVisibility := "public"
(Compile / avroSource) := (Compile / sourceDirectory).value / "avro_source"
(Compile / avroGeneratedSource) := (Compile / sourceManaged).value / "avro"
(Compile / avroGenerate / target) := (Compile / sourceManaged).value / "avro"

0 comments on commit c4ed8ff

Please sign in to comment.