forked from holdenk/spark-testing-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
202 lines (176 loc) · 7.84 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
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")
scalafixDependencies in ThisBuild +=
"com.holdenkarau" %% "spark-scalafix-rules" % "0.1.0-SNAPSHOT"
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-yarn" % sparkVersion.value,
"org.apache.spark" %% "spark-mllib" % sparkVersion.value
) ++ commonDependencies ++ miniClusterDependencies
)
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,
sparkVersion := System.getProperty("sparkVersion", "2.4.0"),
sparkTestingVersion := "1.0.0",
version := sparkVersion.value + "_" + sparkTestingVersion.value,
scalaVersion := {
"2.12.12"
},
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Yrangepos", "-Ywarn-unused-import"),
javacOptions ++= {
Seq("-source", "1.8", "-target", "1.8")
},
javaOptions ++= Seq("-Xms6G", "-Xmx6G", "-XX:MaxPermSize=4048M", "-XX:+CMSClassUnloadingEnabled"),
coverageHighlighting := true,
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")
)
)
// Allow kafka (and other) utils to have version specific files
val coreSources = unmanagedSourceDirectories in Compile := {
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 if (sparkVersion.value >= "2.2.0") Seq(
(sourceDirectory in Compile)(_ / "2.2/scala"),
(sourceDirectory in Compile)(_ / "2.0/scala"), (sourceDirectory in Compile)(_ / "2.0/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)(_ / "2.0/java")
).join.value
}
val coreTestSources = 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)(_ / "2.0/java")
).join.value
else Seq(
(sourceDirectory in Test)(_ / "2.0/scala"), (sourceDirectory in Test)(_ / "2.0/java")
).join.value
}
// additional libraries
lazy val commonDependencies = Seq(
"org.scalatest" %% "scalatest" % "3.0.5",
"io.github.nicolasstucki" %% "multisets" % "0.4",
"org.scalacheck" %% "scalacheck" % "1.14.0",
"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")
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"))
lazy val kafkaPublishSettings =
publishSettings ++ Seq(
skip in publish := scalaVersion.value >= "2.12.0"
)
// publish settings
lazy val publishSettings = Seq(
pomIncludeRepository := { _ => false },
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")),
scmInfo := Some(ScmInfo(
url("https://github.com/holdenk/spark-testing-base.git"),
"scm:git@github.com:holdenk/spark-testing-base.git"
)),
developers := List(
Developer("holdenk", "Holden Karau", "holden@pigscanfly.ca", 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.name + "-" + sparkVersion.value + module.revision + "." + artifact.extension
}
)
lazy val noPublishSettings =
skip in publish := true