-
-
Notifications
You must be signed in to change notification settings - Fork 358
/
build.sbt
289 lines (256 loc) · 10.4 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
import xerial.sbt.Sonatype._
lazy val root = (project in file("."))
.aggregate(core, kafka_0_8)
.settings(noPublishSettings, commonSettings)
val sparkVersion = settingKey[String]("Spark version")
val sparkTestingVersion = settingKey[String]("Spark testing base version without Spark version part")
def specialOptions = {
// We only need these extra props for JRE>17
if (sys.props("java.specification.version") > "1.17") {
Seq(
"base/java.lang", "base/java.lang.invoke", "base/java.lang.reflect", "base/java.io", "base/java.net", "base/java.nio",
"base/java.util", "base/java.util.concurrent", "base/java.util.concurrent.atomic",
"base/sun.nio.ch", "base/sun.nio.cs", "base/sun.security.action",
"base/sun.util.calendar", "security.jgss/sun.security.krb5",
).map("--add-opens=java." + _ + "=ALL-UNNAMED")
} else {
Seq()
}
}
ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
scalafixDependencies in ThisBuild +=
"com.holdenkarau" %% "spark-scalafix-rules" % "0.1.1-2.4.8"
lazy val core = (project in file("core"))
.settings(
name := "spark-testing-base",
commonSettings,
publishSettings,
coreSources,
coreTestSources,
addCompilerPlugin(scalafixSemanticdb),
libraryDependencies ++= Seq(
"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-mllib" % sparkVersion.value
) ++ commonDependencies ++
{
if (sparkVersion.value > "4.0.0") {
Seq(
"org.apache.spark" %% "spark-sql-api" % sparkVersion.value,
"io.netty" % "netty-all" % "4.1.96.Final",
"io.netty" % "netty-tcnative-classes" % "2.0.66.Final",
"com.github.luben" % "zstd-jni" % "1.5.5-4"
)
} else if (sparkVersion.value > "3.0.0") {
Seq(
"io.netty" % "netty-all" % "4.1.77.Final",
"io.netty" % "netty-tcnative-classes" % "2.0.52.Final"
)
} else {
// need a more recent version of xbean for Spark 2.4 so we support JDK11
Seq(
"org.apache.xbean" % "xbean-asm6-shaded" % "4.10",
)
}}
)
lazy val kafka_0_8 = {
Project("kafka_0_8", file("kafka-0.8"))
.dependsOn(core)
.settings(
name := "spark-testing-kafka-0_8",
commonSettings,
kafkaPublishSettings,
unmanagedSourceDirectories in Compile := {
if (scalaVersion.value < "2.12.0")
(unmanagedSourceDirectories in Compile).value
else Seq.empty
},
unmanagedSourceDirectories in Test := {
if (scalaVersion.value < "2.12.0")
(unmanagedSourceDirectories in Test).value
else Seq.empty
},
skip in compile := {
scalaVersion.value >= "2.12.0"
},
skip in test := {
scalaVersion.value >= "2.12.0"
},
skip in publish := {
scalaVersion.value >= "2.12.0"
},
libraryDependencies ++= {
excludeJpountz(
if (scalaVersion.value >= "2.12.0") {
Seq()
} else {
Seq(
"org.apache.spark" %% "spark-streaming-kafka-0-8" % sparkVersion.value)
}
)
}
)
}
val commonSettings = Seq(
organization := "com.holdenkarau",
publishMavenStyle := true,
libraryDependencySchemes += "com.github.luben" %% "zstd-jni" % "early-semver", // "early-semver",
evictionErrorLevel := Level.Info,
sparkVersion := System.getProperty("sparkVersion", "2.4.8"),
sparkTestingVersion := "2.0.0",
version := sparkVersion.value + "_" + sparkTestingVersion.value,
scalaVersion := {
if (sparkVersion.value >= "4.0.0") {
"2.13.13"
} else {
"2.12.15"
}
},
crossScalaVersions := {
if (sparkVersion.value >= "4.0.0") {
Seq("2.13.13")
} else if (sparkVersion.value >= "3.5.0") {
Seq("2.12.15", "2.13.13")
} else if (sparkVersion.value >= "3.2.0") {
Seq("2.12.15", "2.13.10")
} else if (sparkVersion.value >= "3.0.0") {
Seq("2.12.15")
} else {
Seq("2.12.15", "2.11.12")
}
},
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Yrangepos"),
javacOptions ++= {
if (sparkVersion.value >= "4.0.0") {
Seq("-source", "17", "-target", "17")
} else {
Seq("-source", "1.8", "-target", "1.8")
}
},
javaOptions ++= Seq("-Xms8G", "-Xmx8G"),
coverageHighlighting := true,
Test / javaOptions ++= specialOptions,
parallelExecution in Test := false,
fork := true,
scalastyleSources in Compile ++= {unmanagedSourceDirectories in Compile}.value,
scalastyleSources in Test ++= {unmanagedSourceDirectories in Test}.value,
resolvers ++= Seq(
"JBoss Repository" at "https://repository.jboss.org/nexus/content/repositories/releases/",
"Cloudera Repository" at "https://repository.cloudera.com/artifactory/cloudera-repos/",
"Apache HBase" at "https://repository.apache.org/content/repositories/releases",
"Twitter Maven Repo" at "https://maven.twttr.com/",
"scala-tools" at "https://oss.sonatype.org/content/groups/scala-tools",
"sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/",
"Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/",
"Second Typesafe repo" at "https://repo.typesafe.com/typesafe/maven-releases/",
"Mesosphere Public Repository" at "https://downloads.mesosphere.io/maven",
Resolver.sonatypeRepo("public"),
Resolver.mavenLocal
)
)
// Allow kafka (and other) utils to have version specific files
val coreSources = unmanagedSourceDirectories in Compile := {
if (sparkVersion.value >= "4.0.0") Seq(
(sourceDirectory in Compile)(_ / "4.0/scala"),
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "3.0/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "2.0/java")
).join.value
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"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "2.0/java")
).join.value
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"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "2.0/java")
).join.value
else if (sparkVersion.value >= "2.4.0" && scalaVersion.value >= "2.12.0") Seq(
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"), (sourceDirectory in Compile)(_ / "2.0/java")
).join.value
else Seq( // For scala 2.11 only bother building scala support, skip java bridge.
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala")
).join.value
}
val coreTestSources = unmanagedSourceDirectories in Test := {
if (sparkVersion.value >= "4.0.0" && scalaVersion.value >= "2.12.0") Seq(
(sourceDirectory in Test)(_ / "4.0/scala"),
(sourceDirectory in Test)(_ / "3.0/scala"),
(sourceDirectory in Test)(_ / "3.0/java"),
(sourceDirectory in Test)(_ / "2.2/scala"),
(sourceDirectory in Test)(_ / "2.0/scala"),
(sourceDirectory in Test)(_ / "2.0/java")
).join.value
else if (sparkVersion.value >= "3.0.0" && scalaVersion.value >= "2.12.0") Seq(
(sourceDirectory in Test)(_ / "pre-4.0/scala"),
(sourceDirectory in Test)(_ / "3.0/scala"),
(sourceDirectory in Test)(_ / "3.0/java"),
(sourceDirectory in Test)(_ / "2.2/scala"),
(sourceDirectory in Test)(_ / "2.0/scala"),
(sourceDirectory in Test)(_ / "2.0/java")
).join.value
else if (sparkVersion.value >= "2.2.0" && scalaVersion.value >= "2.12.0") Seq(
(sourceDirectory in Test)(_ / "2.2/scala"),
(sourceDirectory in Test)(_ / "2.0/scala"), (sourceDirectory in Test)(_ / "2.0/java")
).join.value
else Seq(
(sourceDirectory in Test)(_ / "2.2/scala"),
(sourceDirectory in Test)(_ / "2.0/scala")
).join.value
}
// additional libraries
lazy val commonDependencies = Seq(
"org.scalatest" %% "scalatest" % "3.2.17",
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0",
"org.scalatestplus" %% "junit-4-13" % "3.2.19.0",
"org.scalacheck" %% "scalacheck" % "1.15.2",
"junit" % "junit" % "4.13.2",
"org.eclipse.jetty" % "jetty-util" % "9.4.51.v20230217",
"com.github.sbt" % "junit-interface" % "0.13.3" % "test->default")
// Based on Hadoop Mini Cluster tests from Alpine's PluginSDK (Apache licensed)
// javax.servlet signing issues can be tricky, we can just exclude the dep
def excludeFromAll(items: Seq[ModuleID], group: String, artifact: String) =
items.map(_.exclude(group, artifact))
def excludeJavaxServlet(items: Seq[ModuleID]) =
excludeFromAll(items, "javax.servlet", "servlet-api")
def excludeJpountz(items: Seq[ModuleID]) =
excludeFromAll(items, "net.jpountz.lz4", "lz4")
lazy val kafkaPublishSettings =
publishSettings ++ Seq(
skip in publish := scalaVersion.value >= "2.12.0"
)
// publish settings
lazy val publishSettings = Seq(
pomIncludeRepository := { _ => false },
publishTo := sonatypePublishToBundle.value,
sonatypeCredentialHost := sonatypeCentralHost,
licenses := Seq("Apache License 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")),
homepage := Some(url("https://github.com/holdenk/spark-testing-base")),
scmInfo := Some(ScmInfo(
url("https://github.com/holdenk/spark-testing-base.git"),
"scm:[email protected]:holdenk/spark-testing-base.git"
)),
developers := List(
Developer("holdenk", "Holden Karau", "[email protected]", url("http://www.holdenkarau.com"))
),
//credentials += Credentials(Path.userHome / ".ivy2" / ".spcredentials")
credentials ++= Seq(Credentials(Path.userHome / ".ivy2" / ".sbtcredentials"), Credentials(Path.userHome / ".ivy2" / ".sparkcredentials")),
useGpg := true,
artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
Artifact.artifactName(sv, module, artifact).replaceAll(s"-${module.revision}", s"-${sparkVersion.value}${module.revision}")
}
)
lazy val noPublishSettings = {
skip in publish := true
}