Skip to content

Commit

Permalink
Add some tags to build.sbt for the components and packages chapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Nov 3, 2024
1 parent 4e2719c commit 9af5c90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ lazy val root = (project in file("."))
.aggregate(core, kafka_0_8)
.settings(noPublishSettings, commonSettings)

//tag::sparkVersion[]
val sparkVersion = settingKey[String]("Spark version")
//end::sparkVersion[]
val sparkTestingVersion = settingKey[String]("Spark testing base version without Spark version part")

def specialOptions = {
Expand Down Expand Up @@ -119,6 +121,7 @@ val commonSettings = Seq(
"2.12.15"
}
},
//tag::dynamicScalaVersion[]
crossScalaVersions := {
if (sparkVersion.value >= "4.0.0") {
Seq("2.13.13")
Expand All @@ -132,6 +135,7 @@ val commonSettings = Seq(
Seq("2.12.15", "2.11.12")
}
},
//end::dynamicScalaVersion[]
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Yrangepos"),
javacOptions ++= {
if (sparkVersion.value >= "4.0.0") {
Expand Down Expand Up @@ -168,6 +172,7 @@ val commonSettings = Seq(
)

// Allow kafka (and other) utils to have version specific files
//tag::dynamicCodeSelection[]
val coreSources = unmanagedSourceDirectories in Compile := {
if (sparkVersion.value >= "4.0.0") Seq(
(sourceDirectory in Compile)(_ / "4.0/scala"),
Expand All @@ -182,6 +187,7 @@ val coreSources = unmanagedSourceDirectories in Compile := {
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "2.0/java")
).join.value
//endDynamicCodeSelection[]
else if (sparkVersion.value >= "3.0.0" && scalaVersion.value >= "2.12.0") Seq(
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "3.0/scala"),
Expand Down

0 comments on commit 9af5c90

Please sign in to comment.