-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.sbt
200 lines (183 loc) · 6.5 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
val projectName = IO.readLines(new File("PROJECT_NAME")).head
val v = IO.readLines(new File("VERSION")).head
val sparkVersions: List[String] = IO.readLines(new File("sparkVersions")).map(_.trim)
val Scala11 = "2.11.12"
val Scala12 = "2.12.17"
val Scala13 = "2.13.10"
val Spark23 = "2.3.4"
val Spark24 = "2.4.8"
val Spark31 = "3.1.3"
val Spark32 = "3.2.3"
val Spark33 = "3.3.1"
val sparkVersionSystem = System.getProperty("sparkVersion", sparkVersions.head)
val sparkVersion = settingKey[String]("Spark version")
lazy val rootSettings =
Seq(
organization := "com.leobenkel",
homepage := Some(url("https://github.com/leobenkel/ZparkIO")),
licenses := List("MIT" -> url("https://opensource.org/licenses/MIT")),
developers :=
List(
Developer(
"leobenkel",
"Leo Benkel",
"",
url("https://leobenkel.com")
)
),
sparkVersion := sparkVersionSystem,
crossScalaVersions := {
sparkVersion.value match {
case Spark23 => Seq(Scala11)
case Spark24 => Seq(Scala12, Scala11)
case Spark31 => Seq(Scala12)
case Spark32 => Seq(Scala13, Scala12)
case Spark33 => Seq(Scala13, Scala12)
case s =>
throw new Exception(s"crossScalaVersions: Do not know what to do with spark version $s")
}
},
scalaVersion := crossScalaVersions.value.head,
resolvers ++= Resolver.sonatypeOssRepos("releases"),
soteriaAddSemantic := false,
version ~= (v => s"${sparkVersionSystem}_$v"),
dynver ~= (v => s"${sparkVersionSystem}_$v")
)
lazy val zioVersion = "2.0.10"
lazy val commonSettings =
rootSettings ++
Seq(
libraryDependencies ++=
Seq(
// https://zio.dev/docs/getting_started.html
"dev.zio" %% "zio" % zioVersion,
// SPARK
"org.apache.spark" %% "spark-core" % sparkVersion.value,
"org.apache.spark" %% "spark-streaming" % sparkVersion.value,
"org.apache.spark" %% "spark-sql" % sparkVersion.value,
"org.apache.spark" %% "spark-hive" % sparkVersion.value,
"org.apache.spark" %% "spark-catalyst" % sparkVersion.value,
"org.apache.spark" %% "spark-yarn" % sparkVersion.value,
"org.apache.spark" %% "spark-mllib" % sparkVersion.value,
// TEST
"org.scalatest" %% "scalatest" % "3.2.16" % Test
),
libraryDependencies ++= {
sparkVersion.value match {
case Spark23 | Spark24 => Seq(
"org.apache.xbean" % "xbean-asm6-shaded" % "4.10"
)
case Spark31 | Spark32 | Spark33 => Seq(
"io.netty" % "netty-all" % "4.1.94.Final",
"io.netty" % "netty-buffer" % "4.1.94.Final",
"io.netty" % "netty-tcnative-classes" % "2.0.61.Final"
)
case _ => Seq.empty
}
},
updateOptions := updateOptions.value.withGigahorse(false),
Test / publishArtifact := false,
pomIncludeRepository := (_ => false),
scalacOptions ++= {
scalaVersion.value match {
case Scala11 | Scala12 => Seq(
"-Ywarn-inaccessible",
"-Ywarn-unused-import"
)
case Scala13 => Seq.empty
case s => throw new Exception(s"scalacOptions: Unknown mapping for scala version $s")
}
}
// Can be needed in the future
// Compile / unmanagedSourceDirectories ++= {
// val pathWith: String => File = (p: String) => baseDirectory.value / "src" / "main" / p
// scalaVersion.value match {
// case Scala13 => Seq(pathWith("scala2.13"))
// case Scala11 | Scala12 => Seq(pathWith("scala2"))
// case s => throw new Exception(
// s"unmanagedSourceDirectories: Unknown mapping for scala version $s"
// )
// }
// }
)
lazy val root = (project in file("."))
.aggregate(library, testHelper, tests, example1Mini, example2Small)
.settings(
name := s"${projectName}_root",
rootSettings
)
lazy val library = (project in file("Library")).settings(
commonSettings,
name := projectName
)
lazy val sparkTestingBaseVersion: String =
sparkVersionSystem match {
// https://mvnrepository.com/artifact/com.holdenkarau/spark-testing-base
case Spark23 => "2.3.3_0.14.0"
case Spark24 => "2.4.8_1.3.0"
case Spark31 => "3.1.2_1.3.0"
case Spark32 => "3.2.2_1.3.0"
case Spark33 => "3.4.0_1.4.3"
case s => throw new Exception(s"sparkTestingBaseVersion: Unknown mapping for spark version $s")
}
lazy val testHelper = (project in file("testModules/TestHelper"))
.settings(
commonSettings,
name := s"$projectName-test",
libraryDependencies ++=
Seq(
"com.holdenkarau" %% "spark-testing-base" % sparkTestingBaseVersion,
"org.apache.spark" %% "spark-hive" % sparkVersion.value % Provided
)
)
.dependsOn(library)
lazy val tests = (project in file("testModules/Tests"))
.settings(
commonSettings,
name := s"${projectName}_tests",
publish / skip := true
)
.dependsOn(
library,
testHelper % Test
)
lazy val libraryConfigsScallop = (project in file("configLibs/Scallop"))
.settings(
commonSettings,
name := s"$projectName-config-scallop",
libraryDependencies ++=
Seq(
// https://github.com/scallop/scallop
"org.rogach" %% "scallop" % "4.1.0"
)
)
.dependsOn(library)
lazy val example1Mini = (project in file("examples/Example1_mini"))
.settings(
commonSettings,
name := s"${projectName}_example1_mini",
publish / skip := true,
assembly / assemblyOption := soteriaAssemblySettings.value
)
.enablePlugins(DockerPlugin)
.dependsOn(
library,
libraryConfigsScallop,
testHelper % Test
)
lazy val example2Small = (project in file("examples/Example2_small"))
.settings(
commonSettings,
name := s"${projectName}_example2_small",
publish / skip := true,
assembly / assemblyOption := soteriaAssemblySettings.value
)
.enablePlugins(DockerPlugin)
.dependsOn(
library,
libraryConfigsScallop,
testHelper % Test
)
// https://github.com/sbt/sbt/issues/6997#issuecomment-1310637232
ThisBuild / libraryDependencySchemes +=
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always