-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package, publish and unpack avro schema artifact (#18)
* Package, publish and unpack avro schema artifact * Update README * Fix caching and use separate target directory * Introduce avroDependencyIncludeFilter setting Extract avro schema from any desired dependency * Use target setting * Unpack avro sources dependencies in sourceManaged folder Co-authored-by: Neville Li <neville@spotify.com>
- Loading branch information
1 parent
dfa04ef
commit 3581fe7
Showing
13 changed files
with
294 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import sbt.Keys.scalaVersion | ||
|
||
lazy val commonSettings = Seq( | ||
organization := "com.cavorite", | ||
publishTo := Some(Opts.resolver.sonatypeReleases), | ||
libraryDependencies ++= Seq( | ||
"org.apache.avro" % "avro" % "1.9.2" | ||
) | ||
) | ||
|
||
lazy val `external`: Project = project | ||
.in(file("external")) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "external", | ||
version := "0.0.1-SNAPSHOT", | ||
crossPaths := false, | ||
autoScalaLibrary := false, | ||
packageAvro / publishArtifact := true | ||
) | ||
|
||
lazy val `transitive`: Project = project | ||
.in(file("transitive")) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "transitive", | ||
version := "0.0.1-SNAPSHOT", | ||
scalaVersion := "2.12.11", | ||
packageAvro / publishArtifact := true, | ||
libraryDependencies ++= Seq( | ||
"com.cavorite" % "external" % "0.0.1-SNAPSHOT" classifier "avro", | ||
) | ||
) | ||
|
||
lazy val root: Project = project | ||
.in(file(".")) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "publishing-test", | ||
scalaVersion := "2.12.11", | ||
avroDependencyIncludeFilter := avroDependencyIncludeFilter.value || | ||
// add avro jar to unpack its json avsc schema | ||
moduleFilter(organization = "org.apache.avro", name = "avro"), | ||
libraryDependencies ++= Seq( | ||
"com.cavorite" %% "transitive" % "0.0.1-SNAPSHOT" classifier "avro", | ||
"org.specs2" %% "specs2-core" % "3.10.0" % "test" | ||
) | ||
) |
6 changes: 6 additions & 0 deletions
6
src/sbt-test/sbt-avro/publishing/external/src/main/avro/com/cavorite/external/avdl.avdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@namespace("com.cavorite.external") | ||
protocol ProtocolAvdl { | ||
record Avdl { | ||
string stringField; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/sbt-test/sbt-avro/publishing/external/src/main/avro/com/cavorite/external/avpr.avpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"namespace": "com.cavorite.external", | ||
"protocol": "ProtocolAvpr", | ||
"types": [ | ||
{ | ||
"name": "Avpr", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
src/sbt-test/sbt-avro/publishing/external/src/main/avro/com/cavorite/external/avsc.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "Avsc", | ||
"namespace": "com.cavorite.external", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.cavorite" % "sbt-avro" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} | ||
|
||
libraryDependencies += "org.apache.avro" % "avro-compiler" % "1.9.2" |
11 changes: 11 additions & 0 deletions
11
src/sbt-test/sbt-avro/publishing/src/main/scala/com/cavorite/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import com.cavorite.external | ||
import com.cavorite.transitive | ||
|
||
|
||
object Main extends App { | ||
|
||
external.Avsc.newBuilder().setStringField("external").build() | ||
transitive.Avsc.newBuilder().setStringField("transitive").build() | ||
|
||
println("success") | ||
} |
Oops, something went wrong.