-
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.
Allow dependency on project with avro scope
- Loading branch information
1 parent
0b66df7
commit 31385b9
Showing
12 changed files
with
189 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
val checkUnpacked = TaskKey[Unit]("checkUnpacked") | ||
val checkGenerated = TaskKey[Unit]("checkGenerated") | ||
|
||
def exists(f: File): Unit = assert(f.exists(), s"$f does not exist") | ||
def absent(f: File): Unit = assert(!f.exists(), s"$f does exists") | ||
|
||
lazy val commonSettings = Seq( | ||
organization := "com.github.sbt", | ||
scalaVersion := "2.13.15" | ||
) | ||
|
||
lazy val avroOnlySettings = Seq( | ||
crossScalaVersions := Seq.empty, | ||
crossPaths := false, | ||
autoScalaLibrary := false, | ||
// only create avro jar | ||
Compile / packageAvro / publishArtifact := true, | ||
Compile / packageBin / publishArtifact := false, | ||
Compile / packageSrc / publishArtifact := false, | ||
Compile / packageDoc / publishArtifact := false, | ||
) | ||
|
||
lazy val `external`: Project = project | ||
.in(file("external")) | ||
.enablePlugins(SbtAvro) | ||
.settings(commonSettings) | ||
.settings(avroOnlySettings) | ||
.settings( | ||
name := "external", | ||
version := "0.0.1-SNAPSHOT", | ||
) | ||
|
||
lazy val `transitive`: Project = project | ||
.in(file("transitive")) | ||
.enablePlugins(SbtAvro) | ||
.settings(commonSettings) | ||
.settings(avroOnlySettings) | ||
.settings( | ||
name := "transitive", | ||
version := "0.0.1-SNAPSHOT", | ||
libraryDependencies ++= Seq( | ||
// when using avro scope, it won't be part of the pom dependencies -> intransitive | ||
// to declare transitive dependency use the compile scope | ||
"com.github.sbt" % "external" % "0.0.1-SNAPSHOT" classifier "avro" | ||
), | ||
Compile / avroDependencyIncludeFilter := artifactFilter(classifier = "avro"), | ||
// create a test jar with a schema as resource | ||
Test / packageBin / publishArtifact := true, | ||
) | ||
|
||
lazy val root: Project = project | ||
.in(file(".")) | ||
.enablePlugins(SbtAvro) | ||
.dependsOn(`transitive` % "avro->avro") | ||
.settings(commonSettings) | ||
.settings( | ||
name := "local-dependency", | ||
crossScalaVersions := Seq("2.13.15", "2.12.20"), | ||
libraryDependencies ++= Seq( | ||
"org.specs2" %% "specs2-core" % "4.20.9" % Test | ||
), | ||
// add additional avro source test jar | ||
Test / avroDependencyIncludeFilter := artifactFilter(name = "transitive", classifier = "tests"), | ||
|
||
Compile / checkUnpacked := { | ||
exists((`transitive` / crossTarget).value / "src_managed" / "avro" / "main" / "external-avro" / "avdl.avdl") | ||
exists((`transitive` / crossTarget).value / "src_managed" / "avro" / "main" / "external-avro" / "avpr.avpr") | ||
exists((`transitive` / crossTarget).value / "src_managed" / "avro" / "main" / "external-avro" / "avsc.avsc") | ||
}, | ||
Compile / checkGenerated := { | ||
exists(crossTarget.value / "src_managed" / "compiled_avro" / "main" / "com" / "github" / "sbt" / "avro" / "test" / "external" / "Avdl.java") | ||
exists(crossTarget.value / "src_managed" / "compiled_avro" / "main" / "com" / "github" / "sbt" / "avro" / "test" / "external" / "Avpr.java") | ||
exists(crossTarget.value / "src_managed" / "compiled_avro" / "main" / "com" / "github" / "sbt" / "avro" / "test" / "external" / "Avsc.java") | ||
exists(crossTarget.value / "src_managed" / "compiled_avro" / "main" / "com" / "github" / "sbt" / "avro" / "test" / "transitive" / "Avsc.java") | ||
} | ||
) |
6 changes: 6 additions & 0 deletions
6
plugin/src/sbt-test/sbt-avro/local-dependency/external/src/main/avro/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.github.sbt.avro.test.external") | ||
protocol ProtocolAvdl { | ||
record Avdl { | ||
string stringField; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
plugin/src/sbt-test/sbt-avro/local-dependency/external/src/main/avro/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.github.sbt.avro.test.external", | ||
"protocol": "ProtocolAvpr", | ||
"types": [ | ||
{ | ||
"name": "Avpr", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
plugin/src/sbt-test/sbt-avro/local-dependency/external/src/main/avro/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.github.sbt.avro.test.external", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
plugin/src/sbt-test/sbt-avro/local-dependency/project/plugins.sbt
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,5 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.github.sbt" % "sbt-avro" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/sbt-test/sbt-avro/local-dependency/src/main/scala/com/github/sbt/avro/test/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 @@ | ||
package com.github.sbt.avro.test | ||
|
||
object Main extends App { | ||
|
||
external.Avsc.newBuilder().setStringField("external").build() | ||
external.Avpr.newBuilder().setStringField("external").build() | ||
external.Avdl.newBuilder().setStringField("external").build() | ||
transitive.Avsc.newBuilder().setStringField("transitive").build() | ||
|
||
println("success") | ||
} |
10 changes: 10 additions & 0 deletions
10
...sbt-test/sbt-avro/local-dependency/src/test/scala/com/github/sbt/avro/test/AvroTest.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,10 @@ | ||
package com.github.sbt.avro.test | ||
|
||
import com.github.sbt.avro.test.transitive.Test | ||
|
||
object AvroTest extends App { | ||
|
||
Test.newBuilder().setStringField("external").build() | ||
|
||
println("success") | ||
} |
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 @@ | ||
> external/publishLocal | ||
|
||
> avroGenerate | ||
> checkUnpacked | ||
> checkGenerated | ||
|
||
> +compile |
15 changes: 15 additions & 0 deletions
15
...o/local-dependency/transitive/src/main/avro/com/github/sbt/avro/test/transitive/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,15 @@ | ||
{ | ||
"name": "Avsc", | ||
"namespace": "com.github.sbt.avro.test.transitive", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "referencedTypeField", | ||
"type": "com.github.sbt.avro.test.external.Avsc" | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
plugin/src/sbt-test/sbt-avro/local-dependency/transitive/src/test/resources/test.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,15 @@ | ||
{ | ||
"name": "Test", | ||
"namespace": "com.github.sbt.avro.test.transitive", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "stringField", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "referencedTypeField", | ||
"type": "com.github.sbt.avro.test.external.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