forked from spark-notebook/spark-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
242 lines (199 loc) · 7.63 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
import Dependencies._
import Shared._
import sbtbuildinfo.Plugin._
organization := "noootsab"
name := "spark-notebook"
scalaVersion := defaultScalaVersion
version in ThisBuild <<= (scalaVersion, sparkVersion, hadoopVersion, withHive, withParquet) { (sc, sv, hv, h, p) =>
s"0.6.0-scala-$sc-spark-$sv-hadoop-$hv" + (if (h) "-with-hive" else "") + (if (p) "-with-parquet" else "")
}
maintainer := "Andy Petrella" //Docker
enablePlugins(UniversalPlugin)
enablePlugins(DockerPlugin)
import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper._
import com.typesafe.sbt.packager.docker._
// java image based on ubuntu trusty rather than debian jessie (to use mesosphere distros)
// build it like this:
// ```
// docker build -t="dockerfile/ubuntu" github.com/dockerfile/ubuntu
// git clone https://github.com/dockerfile/java.git
// cd java
// cd openjdk-7-jdk
// docker build -t="dockerfile/java:openjdk-7-jdk" .
// ```
dockerBaseImage := "dockerfile/java:openjdk-7-jdk"
dockerCommands ++= Seq(
Cmd("USER", "root"),
Cmd("RUN", "apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF"),
Cmd("RUN", "echo \"deb http://repos.mesosphere.io/ubuntu trusty main\" | tee /etc/apt/sources.list.d/mesosphere.list"),
Cmd("RUN", "/usr/bin/apt-get -y update --fix-missing"),
Cmd("RUN", s"/usr/bin/apt-get -y install mesos=$mesosVersion-1.0.ubuntu1404"), //ubuntu 14.04 is base for java:latest → https://github.com/dockerfile/ubuntu/blob/master/Dockerfile
Cmd("ENV", s"MESOS_JAVA_NATIVE_LIBRARY /usr/local/lib/libmesos-$mesosVersion.so"),
Cmd("ENV", s"MESOS_LOG_DIR /var/log/mesos"),
Cmd("USER", (daemonUser in Docker).value)
)
dockerExposedVolumes ++= Seq("/opt/docker/notebooks", "/opt/docker/logs")
dockerExposedPorts ++= Seq(9000, 9443) //Docker
dockerRepository := Some("andypetrella") //Docker
packageName in Docker := "spark-notebook"
ivyScala := ivyScala.value map {
_.copy(overrideScalaVersion = true)
}
parallelExecution in Test in ThisBuild := false
// these java options are for the forked test JVMs
javaOptions in ThisBuild ++= Seq("-Xmx512M", "-XX:MaxPermSize=128M")
resolvers in ThisBuild ++= Seq(
Resolver.mavenLocal,
Resolver.typesafeRepo("releases"),
Resolver.sonatypeRepo("releases"),
Resolver.typesafeIvyRepo("releases"),
Resolver.typesafeIvyRepo("snapshots"),
"cloudera" at "https://repository.cloudera.com/artifactory/cloudera-repos",
// docker
"softprops-maven" at "http://dl.bintray.com/content/softprops/maven",
//spark 1.4
"Apache Spark Prerelease" at "https://repository.apache.org/content/repositories/orgapachespark-1092/"
)
EclipseKeys.skipParents in ThisBuild := false
compileOrder := CompileOrder.Mixed
publishMavenStyle := false
javacOptions ++= Seq("-Xlint:deprecation", "-g")
scalacOptions += "-deprecation"
scalacOptions ++= Seq("-Xmax-classfile-name", "100")
val ClasspathPattern = "declare -r app_classpath=\"(.*)\"\n".r
bashScriptDefines := bashScriptDefines.value.map {
case ClasspathPattern(classpath) =>
"declare -r app_classpath=\"${HADOOP_CONF_DIR}:${EXTRA_CLASSPATH}:" + classpath + "\"\n"
case _@entry => entry
}
//scriptClasspath += "${HADOOP_CONF_DIR}"
dependencyOverrides += "log4j" % "log4j" % "1.2.16"
dependencyOverrides += guava
enablePlugins(DebianPlugin)
sharedSettings
libraryDependencies ++= playDeps
libraryDependencies ++= List(
akka,
akkaRemote,
akkaSlf4j,
cache,
commonsIO,
// ↓ to fix java.lang.IllegalStateException: impossible to get artifacts when data has
// not been loaded. IvyNode = org.apache.commons#commons-exec;1.1
// encountered when using hadoop "2.0.0-cdh4.2.0"
commonsExec,
commonsCodec,
//scala stuffs
"org.scala-lang" % "scala-library" % defaultScalaVersion,
"org.scala-lang" % "scala-reflect" % defaultScalaVersion,
"org.scala-lang" % "scala-compiler" % defaultScalaVersion
)
//for aether
libraryDependencies <++= scalaBinaryVersion {
case "2.10" => Nil
case "2.11" => List(ningAsyncHttpClient)
}
lazy val sparkNotebook = project.in(file(".")).enablePlugins(play.PlayScala).enablePlugins(SbtWeb)
.aggregate(tachyon, subprocess, observable, common, spark, kernel)
.dependsOn(tachyon, subprocess, observable, common, spark, kernel)
.settings(sharedSettings: _*)
.settings(
mappings in Universal ++= directory("notebooks"),
mappings in Docker ++= directory("notebooks")
)
.settings(includeFilter in(Assets, LessKeys.less) := "*.less")
.settings(unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_))) //avoid app-2.10 and co to be created
.settings(initialCommands += ConsoleHelpers.cleanAllOutputs)
lazy val subprocess = project.in(file("modules/subprocess"))
.settings(libraryDependencies ++= playDeps)
.settings(
libraryDependencies ++= {
Seq(
akka,
akkaRemote,
akkaSlf4j,
commonsIO,
commonsExec,
log4j
)
}
)
.settings(sharedSettings: _*)
.settings(sparkSettings: _*)
lazy val observable = Project(id = "observable", base = file("modules/observable"))
.dependsOn(subprocess)
.settings(
libraryDependencies ++= Seq(
akkaRemote,
akkaSlf4j,
slf4jLog4j,
rxScala
)
)
.settings(sharedSettings: _*)
lazy val common = Project(id = "common", base = file("modules/common"))
.dependsOn(observable)
.settings(
libraryDependencies ++= Seq(
akka,
log4j,
scalaZ
),
libraryDependencies ++= depsToDownloadDeps(scalaBinaryVersion.value, sbtVersion.value),
// plotting functionality
libraryDependencies ++= Seq(
bokeh,
wisp
), // ++ customJacksonScala
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / ("scala-" + scalaBinaryVersion.value),
unmanagedSourceDirectories in Compile +=
(sourceDirectory in Compile).value / ((sparkVersion.value.takeWhile(_ != '-').split("\\.").toList match {
case "1"::x::_ if x.toInt < 3 => "pre-df"
case x => "post-df"
}))
)
.settings(sharedSettings: _*)
.settings(sparkSettings: _*)
.settings(buildInfoSettings: _*)
.settings(
sourceGenerators in Compile <+= buildInfo,
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion, sparkVersion, hadoopVersion, withHive, jets3tVersion, jlineDef, sbtVersion),
buildInfoPackage := "notebook"
)
lazy val spark = Project(id = "spark", base = file("modules/spark"))
.dependsOn(common, subprocess, observable)
.settings(
libraryDependencies ++= Seq(
akkaRemote,
akkaSlf4j,
slf4jLog4j,
commonsIO
),
libraryDependencies ++= Seq(
jlineDef.value._1 % "jline" % jlineDef.value._2,
"org.scala-lang" % "scala-compiler" % scalaVersion.value
),
unmanagedSourceDirectories in Compile +=
(sourceDirectory in Compile).value / ("scala_" + ((scalaBinaryVersion.value, sparkVersion.value.takeWhile(_ != '-')) match {
case (v, sv) if v startsWith "2.10" => "2.10" + "/spark-" + sv
case (v, sv) if v startsWith "2.11" => "2.11" + "/spark-" + sv
case (v, sv) => throw new IllegalArgumentException("Bad scala version: " + v)
}))
)
.settings(sharedSettings: _*)
.settings(sparkSettings: _*)
lazy val tachyon = Project(id = "tachyon", base = file("modules/tachyon"))
.settings(sharedSettings: _*)
.settings(tachyonSettings: _*)
lazy val kernel = Project(id = "kernel", base = file("modules/kernel"))
.dependsOn(common, subprocess, observable, spark)
.settings(
libraryDependencies ++= Seq(
akkaRemote,
akkaSlf4j,
slf4jLog4j,
commonsIO
),
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / ("scala-" + scalaBinaryVersion.value)
)
.settings(sharedSettings: _*)