forked from holdenk/spark-testing-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
259 lines (222 loc) · 10.1 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
organization := "com.holdenkarau"
name := "spark-testing-base"
publishMavenStyle := true
version := "0.11.0"
sparkVersion := "2.4.0"
scalaVersion := {
if (sparkVersion.value >= "2.0.0") {
"2.11.11"
} else {
"2.10.6"
}
}
// See https://github.com/scala/scala/pull/3799
coverageHighlighting := {
if (sparkVersion.value >= "2.0.0") {
true
} else {
false
}
}
crossScalaVersions := {
if (sparkVersion.value >= "2.3.0") {
Seq("2.11.11")
} else {
Seq("2.10.6", "2.11.11")
}
}
javacOptions ++= {
if (sparkVersion.value >= "2.1.1") {
Seq("-source", "1.8", "-target", "1.8")
} else {
Seq("-source", "1.7", "-target", "1.7")
}
}
//tag::spName[]
spName := "holdenk/spark-testing-base"
//end::spName[]
sparkComponents := {
if (sparkVersion.value >= "2.3.0") Seq("core", "streaming", "sql", "catalyst", "hive", "yarn", "mllib")
else if (sparkVersion.value >= "2.0.0") Seq("core", "streaming", "sql", "catalyst", "hive", "yarn", "mllib", "streaming-kafka-0-8")
else Seq("core", "streaming", "sql", "catalyst", "hive", "streaming-kafka", "yarn", "mllib")
}
parallelExecution in Test := false
fork := true
coverageHighlighting := {
if (scalaBinaryVersion.value == "2.10") false
else true
}
scalastyleSources in Compile ++= {unmanagedSourceDirectories in Compile}.value
scalastyleSources in Test ++= {unmanagedSourceDirectories in Test}.value
// Allow kafka (and other) utils to have version specific files
unmanagedSourceDirectories in Compile := {
if (sparkVersion.value >= "2.2.0") Seq(
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "1.6/scala"),
(sourceDirectory in Compile)(_ / "1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "2.0.0" && scalaVersion.value >= "2.11") Seq(
(sourceDirectory in Compile)(_ / "pre-2.2_2.11/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "1.6/scala"),
(sourceDirectory in Compile)(_ / "1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "2.0.0") Seq(
(sourceDirectory in Compile)(_ / "pre-2.2_2.10/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"),
(sourceDirectory in Compile)(_ / "1.6/scala"),
(sourceDirectory in Compile)(_ / "1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "1.6") Seq(
(sourceDirectory in Compile)(_ / "pre-2.0/scala"),
(sourceDirectory in Compile)(_ / "1.6/scala"),
(sourceDirectory in Compile)(_ / "1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "1.5") Seq(
(sourceDirectory in Compile)(_ / "pre-2.0/scala"),
(sourceDirectory in Compile)(_ / "1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "1.4") Seq(
(sourceDirectory in Compile)(_ / "pre-2.0/scala"),
(sourceDirectory in Compile)(_ / "pre-1.5/scala"),
(sourceDirectory in Compile)(_ / "1.4/scala"),
(sourceDirectory in Compile)(_ / "kafka/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java")
).join.value
else Seq(
(sourceDirectory in Compile)(_ / "pre-2.0/scala"),
(sourceDirectory in Compile)(_ / "pre-1.5/scala"),
(sourceDirectory in Compile)(_ / "1.3/scala"), (sourceDirectory in Compile)(_ / "1.3/java"),
(sourceDirectory in Compile)(_ / "1.3-only/scala")
).join.value
}
unmanagedSourceDirectories in Test := {
if (sparkVersion.value >= "2.2.0") Seq(
(sourceDirectory in Test)(_ / "2.2/scala"),
(sourceDirectory in Test)(_ / "2.0/scala"),
(sourceDirectory in Test)(_ / "1.6/scala"), (sourceDirectory in Test)(_ / "1.6/java"),
(sourceDirectory in Test)(_ / "1.4/scala"),
(sourceDirectory in Test)(_ / "kafka/scala"),
(sourceDirectory in Test)(_ / "1.3/scala"), (sourceDirectory in Test)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "2.0.0") Seq(
(sourceDirectory in Test)(_ / "2.0/scala"),
(sourceDirectory in Test)(_ / "1.6/scala"), (sourceDirectory in Test)(_ / "1.6/java"),
(sourceDirectory in Test)(_ / "1.4/scala"),
(sourceDirectory in Test)(_ / "kafka/scala"),
(sourceDirectory in Test)(_ / "1.3/scala"), (sourceDirectory in Test)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "1.6") Seq(
(sourceDirectory in Test)(_ / "pre-2.0/scala"), (sourceDirectory in Test)(_ / "pre-2.0/java"),
(sourceDirectory in Test)(_ / "1.6/scala"), (sourceDirectory in Test)(_ / "1.6/java"),
(sourceDirectory in Test)(_ / "1.4/scala"),
(sourceDirectory in Test)(_ / "kafka/scala"),
(sourceDirectory in Test)(_ / "1.3/scala"), (sourceDirectory in Test)(_ / "1.3/java")
).join.value
else if (sparkVersion.value >= "1.4") Seq(
(sourceDirectory in Test)(_ / "pre-2.0/scala"), (sourceDirectory in Test)(_ / "pre-2.0/java"),
(sourceDirectory in Test)(_ / "1.4/scala"),
(sourceDirectory in Test)(_ / "kafka/scala"),
(sourceDirectory in Test)(_ / "1.3/scala"), (sourceDirectory in Test)(_ / "1.3/java")
).join.value
else Seq(
(sourceDirectory in Test)(_ / "pre-2.0/scala"), (sourceDirectory in Test)(_ / "pre-2.0/java"),
(sourceDirectory in Test)(_ / "1.3/scala"), (sourceDirectory in Test)(_ / "1.3/java")
).join.value
}
javaOptions ++= Seq("-Xms2G", "-Xmx2G", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")
// additional libraries
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1",
"io.github.nicolasstucki" %% "multisets" % "0.4",
"org.scalacheck" %% "scalacheck" % "1.13.4",
"junit" % "junit" % "4.12",
"org.eclipse.jetty" % "jetty-util" % "9.3.11.v20160721",
"com.novocode" % "junit-interface" % "0.11" % "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")
libraryDependencies ++= excludeJpountz(
// For Spark 2.4 w/ Scala 2.12 we're going to need some special logic
if (sparkVersion.value >= "2.3.0") {
Seq(
"org.apache.spark" %% "spark-streaming-kafka-0-8" % sparkVersion.value
)
} else {
// We still have Kafka it's just done through sparkComponents
Seq()
}
)
lazy val miniClusterDependencies = excludeJavaxServlet(Seq(
"org.apache.hadoop" % "hadoop-hdfs" % "2.8.3" % "compile,test" classifier "" classifier "tests",
"org.apache.hadoop" % "hadoop-common" % "2.8.3" % "compile,test" classifier "" classifier "tests" ,
"org.apache.hadoop" % "hadoop-client" % "2.8.3" % "compile,test" classifier "" classifier "tests" ,
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % "2.8.3" % "compile,test" classifier "" classifier "tests",
"org.apache.hadoop" % "hadoop-yarn-server-tests" % "2.8.3" % "compile,test" classifier "" classifier "tests",
"org.apache.hadoop" % "hadoop-yarn-server-web-proxy" % "2.8.3" % "compile,test" classifier "" classifier "tests",
"org.apache.hadoop" % "hadoop-minicluster" % "2.8.3" % "compile,test"))
libraryDependencies ++= miniClusterDependencies
scalacOptions ++= Seq("-deprecation", "-unchecked")
pomIncludeRepository := { x => false }
resolvers ++= Seq(
"JBoss Repository" at "http://repository.jboss.org/nexus/content/repositories/releases/",
"Spray Repository" at "http://repo.spray.cc/",
"Cloudera Repository" at "https://repository.cloudera.com/artifactory/cloudera-repos/",
"Apache HBase" at "https://repository.apache.org/content/repositories/releases",
"Twitter Maven Repo" at "http://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 "http://repo.typesafe.com/typesafe/releases/",
"Second Typesafe repo" at "http://repo.typesafe.com/typesafe/maven-releases/",
"Mesosphere Public Repository" at "http://downloads.mesosphere.io/maven",
Resolver.sonatypeRepo("public")
)
// publish settings
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
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"))
pomExtra := (
<scm>
<url>[email protected]:holdenk/spark-testing-base.git</url>
<connection>scm:[email protected]:holdenk/spark-testing-base.git</connection>
</scm>
<developers>
<developer>
<id>holdenk</id>
<name>Holden Karau</name>
<url>http://www.holdenkarau.com</url>
<email>[email protected]</email>
</developer>
</developers>
)
//credentials += Credentials(Path.userHome / ".ivy2" / ".spcredentials")
credentials ++= Seq(Credentials(Path.userHome / ".ivy2" / ".sbtcredentials"), Credentials(Path.userHome / ".ivy2" / ".sparkcredentials"))
spIncludeMaven := true
useGpg := true