forked from d2iq-archive/marathon
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sbt
293 lines (270 loc) · 12.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
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
290
291
292
293
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper.directory
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import com.typesafe.sbt.packager.docker.Cmd
import mesosphere.maven.MavenSettings.{loadM2Credentials, loadM2Resolvers}
import mesosphere.raml.RamlGeneratorPlugin
import sbtprotobuf.ProtobufPlugin
import scalariform.formatter.preferences._
credentials ++= loadM2Credentials(streams.value.log)
credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"criteo-forks",
sys.env.get("GITHUB_TOKEN").get
)
resolvers ++= loadM2Resolvers(sLog.value)
resolvers += Resolver.sonatypeRepo("snapshots")
addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.17")
val silencerVersion = "1.1"
addCompilerPlugin("com.github.ghik" %% "silencer-plugin" % silencerVersion)
libraryDependencies += "com.github.ghik" %% "silencer-lib" % silencerVersion % Provided
lazy val formatSettings = Seq(
ScalariformKeys.preferences := FormattingPreferences()
.setPreference(DanglingCloseParenthesis, Preserve)
.setPreference(DoubleIndentConstructorArguments, true)
.setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
.setPreference(PreserveSpaceBeforeArguments, true)
.setPreference(SpacesAroundMultiImports, false)
)
// Pass arguments to Scalatest runner:
// http://www.scalatest.org/user_guide/using_the_runner
lazy val testSettings = Seq(
parallelExecution in Test := true,
testForkedParallel in Test := true,
testListeners := Nil, // TODO(MARATHON-8215): Remove this line
testOptions in Test := Seq(
Tests.Argument(
"-u", "target/test-reports", // TODO(MARATHON-8215): Remove this line
"-o", "-eDFG",
"-y", "org.scalatest.WordSpec")),
fork in Test := true
)
// Pass arguments to Scalatest runner:
// http://www.scalatest.org/user_guide/using_the_runner
lazy val integrationTestSettings = Seq(
testListeners := Nil, // TODO(MARATHON-8215): Remove this line
fork in Test := true,
testOptions in Test := Seq(
Tests.Argument(
"-u", "target/test-reports", // TODO(MARATHON-8215): Remove this line
"-o", "-eDFG",
"-y", "org.scalatest.WordSpec")),
parallelExecution in Test := true,
testForkedParallel in Test := true,
concurrentRestrictions in Test := Seq(Tags.limitAll(math.max(1, java.lang.Runtime.getRuntime.availableProcessors() / 2))),
javaOptions in (Test, test) ++= Seq(
"-Dakka.actor.default-dispatcher.fork-join-executor.parallelism-min=2",
"-Dakka.actor.default-dispatcher.fork-join-executor.factor=1",
"-Dakka.actor.default-dispatcher.fork-join-executor.parallelism-max=4",
"-Dscala.concurrent.context.minThreads=2",
"-Dscala.concurrent.context.maxThreads=32"
),
concurrentRestrictions in Test := Seq(Tags.limitAll(math.max(1, java.lang.Runtime.getRuntime.availableProcessors() / 2)))
)
// Build Settings for Protobuf (https://github.com/sbt/sbt-protobuf)
//
// version => The version of the protobuf library to be used. An sbt dependency is added for the project
// includeFilter => Specify which files to compile. We need this to exclude the mesos/mesos.proto to be compiled directly
// protobufRunProtoc => Use ProtocJar to use a bundled protoc version, so we don't rely on a preinstalled version. "-v330" defines the protoc version
val pbSettings = ProtobufPlugin.projectSettings ++ Seq(
(version in ProtobufConfig) := "3.3.0",
(includeFilter in ProtobufConfig) := "marathon.proto",
(protobufRunProtoc in ProtobufConfig) := (args => com.github.os72.protocjar.Protoc.runProtoc("-v330" +: args.toArray))
)
lazy val commonSettings = Seq(
autoCompilerPlugins := true,
organization := "mesosphere.marathon",
scalaVersion := "2.12.7",
crossScalaVersions := Seq(scalaVersion.value),
scalacOptions in Compile ++= Seq(
"-encoding", "UTF-8",
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xfuture",
"-Xlint",
//FIXME: CORE-977 and MESOS-7368 are filed and need to be resolved to re-enable this
// "-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
//"-Ywarn-dead-code", We should turn this one on soon
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
//"-Ywarn-unused", We should turn this one on soon
"-Ywarn-unused:-locals,imports",
//"-Ywarn-value-discard", We should turn this one on soon.
),
// Don't need any linting, etc for docs, so gain a small amount of build time there.
scalacOptions in (Compile, doc) := Seq("-encoding", "UTF-8", "-deprecation", "-feature", "-Xfuture"),
javacOptions in Compile ++= Seq(
"-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-Xlint:deprecation"
),
resolvers ++= Seq(
Resolver.JCenterRepository,
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/",
"Apache Shapshots" at "https://repository.apache.org/content/repositories/snapshots/",
"Criteo Forks Marathon" at "https://maven.pkg.github.com/criteo-forks/marathon/"
),
cancelable in Global := true,
publishTo := Some(s3resolver.value(
"Mesosphere Public Repo (S3)",
s3("downloads.mesosphere.io/maven")
)),
s3credentials := DefaultAWSCredentialsProviderChain.getInstance(),
s3region := com.amazonaws.services.s3.model.Region.US_Standard,
fork in run := true
)
/**
* The documentation for sbt-native-package can be foound here:
* - General, non-vendor specific settings (such as launch script):
* http://sbt-native-packager.readthedocs.io/en/latest/archetypes/java_app/index.html#usage
*
* - Linux packaging settings
* http://sbt-native-packager.readthedocs.io/en/latest/archetypes/java_app/index.html#usage
*/
lazy val packagingSettings = Seq(
bashScriptExtraDefines += IO.read((baseDirectory.value / "project" / "NativePackagerSettings" / "extra-defines.bash")),
mappings in (Compile, packageDoc) := Seq(),
(packageName in Universal) := {
import sys.process._
val tag = ("./version tag" !!).trim
s"${packageName.value}-$tag"
},
/* Universal packaging (docs) - http://sbt-native-packager.readthedocs.io/en/latest/formats/universal.html
*/
universalArchiveOptions in (UniversalDocs, packageZipTarball) := Seq("-pcvf"), // Remove this line once fix for https://github.com/sbt/sbt-native-packager/issues/1019 is released
(packageName in UniversalDocs) := {
import sys.process._
val shortCommit = ("./version commit" !!).trim
s"${packageName.value}-docs-${version.value}-$shortCommit"
},
(topLevelDirectory in UniversalDocs) := { Some((packageName in UniversalDocs).value) },
mappings in UniversalDocs ++= directory("docs/docs"),
/* Docker config (http://sbt-native-packager.readthedocs.io/en/latest/formats/docker.html)
*/
dockerBaseImage := "debian:stretch-slim",
dockerRepository := Some("mesosphere"),
daemonUser in Docker := "nobody",
daemonGroup in Docker := "nogroup",
version in Docker := {
import sys.process._
("./version docker" !!).trim
},
(defaultLinuxInstallLocation in Docker) := "/marathon",
maintainer := "Mesosphere Package Builder <[email protected]>",
dockerCommands := {
// kind of a work-around; we need our chown /marathon command to come after the WORKDIR command, and installation
// commands to preceed adding the Marthon artifact so that Docker can cache them
val (prefixCommands, restCommands) = dockerCommands.value.splitAt(dockerCommands.value.indexWhere(_.makeContent.startsWith("WORKDIR ")) + 1)
// Notes on the script below:
//
// 1) The `stretch-slim` does not contain `gnupg` and therefore `apt-key adv` will fail unless it's installed first
// 2) We are creating a dummy `systemctl` binary in order to satisfy mesos post-install script that tries to invoke
// it for registering the systemd task.
//
prefixCommands ++
Seq(Cmd("RUN",
s"""apt-get update && apt-get install -my wget gnupg && \\
|apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv DF7D54CBE56151BF && \\
|apt-get update -y && \\
|apt-get upgrade -y && \\
|${NativePackagerSettings.debianSourceCommands} && \\
|apt-get update && \\
|# jdk setup
|mkdir -p /usr/share/man/man1 && \\
|apt-get install -y openjdk-8-jdk-headless openjdk-8-jre-headless ca-certificates-java && \\
|/var/lib/dpkg/info/ca-certificates-java.postinst configure && \\
|ln -svT "/usr/lib/jvm/java-8-openjdk-$$(dpkg --print-architecture)" /docker-java-home && \\
|# mesos setup
|echo exit 0 > /usr/bin/systemctl && chmod +x /usr/bin/systemctl && \\
|# Workaround required due to https://github.com/mesosphere/mesos-deb-packaging/issues/102
|# Remove after upgrading to Mesos 1.7.0
|apt-get install -y libcurl3-nss && \\
|apt-get install --no-install-recommends -y mesos=${Dependency.V.MesosDebian}.debian9 && \\
|rm /usr/bin/systemctl && \\
|apt-get clean && \\
|chown nobody:nogroup /marathon""".stripMargin)) ++
restCommands ++
Seq(
Cmd("ENV", "JAVA_HOME /docker-java-home"),
Cmd("RUN", s"""ln -sf /marathon/bin/marathon /marathon/bin/start && \\
|chmod a+x /marathon/bin/marathon""".stripMargin))
})
lazy val `plugin-interface` = (project in file("plugin-interface"))
.enablePlugins(GitBranchPrompt, BasicLintingPlugin)
.settings(testSettings : _*)
.settings(commonSettings : _*)
.settings(formatSettings : _*)
.settings(
version := {
import sys.process._
("./version" !!).trim
},
name := "plugin-interface",
libraryDependencies ++= Dependencies.pluginInterface
)
lazy val marathon = (project in file("."))
.enablePlugins(GitBranchPrompt, JavaServerAppPackaging, DockerPlugin,
RamlGeneratorPlugin, BasicLintingPlugin, GitVersioning, ProtobufPlugin)
.dependsOn(`plugin-interface`)
.settings(pbSettings)
.settings(testSettings : _*)
.settings(commonSettings: _*)
.settings(formatSettings: _*)
.settings(packagingSettings: _*)
.settings(
version := {
import sys.process._
("./version" !!).trim
},
unmanagedResourceDirectories in Compile += file("docs/docs/rest-api"),
libraryDependencies ++= Dependencies.marathon,
sourceGenerators in Compile += (ramlGenerate in Compile).taskValue,
mainClass in Compile := Some("mesosphere.marathon.Main"),
packageOptions in (Compile, packageBin) ++= Seq(
Package.ManifestAttributes("Implementation-Version" -> version.value ),
Package.ManifestAttributes("Scala-Version" -> scalaVersion.value ),
Package.ManifestAttributes("Git-Commit" -> git.gitHeadCommit.value.getOrElse("unknown") )
)
)
lazy val ammonite = (project in file("./tools/repl-server"))
.settings(commonSettings: _*)
.settings(formatSettings: _*)
.settings(
mainClass in Compile := Some("ammoniterepl.Main"),
libraryDependencies += "com.lihaoyi" % "ammonite-sshd" % "1.5.0" cross CrossVersion.full
)
.dependsOn(marathon)
lazy val integration = (project in file("./tests/integration"))
.enablePlugins(GitBranchPrompt, BasicLintingPlugin)
.settings(integrationTestSettings : _*)
.settings(commonSettings: _*)
.settings(formatSettings: _*)
.settings(
cleanFiles += baseDirectory { base => base / "sandboxes" }.value
)
.dependsOn(marathon % "test->test")
lazy val `mesos-simulation` = (project in file("mesos-simulation"))
.enablePlugins(GitBranchPrompt, BasicLintingPlugin)
.settings(testSettings : _*)
.settings(commonSettings: _*)
.settings(formatSettings: _*)
.dependsOn(marathon % "compile->compile; test->test")
.settings(
name := "mesos-simulation"
)
// see also, benchmark/README.md
lazy val benchmark = (project in file("benchmark"))
.enablePlugins(JmhPlugin, GitBranchPrompt, BasicLintingPlugin)
.settings(testSettings : _*)
.settings(commonSettings : _*)
.settings(formatSettings: _*)
.dependsOn(marathon % "compile->compile; test->test")
.settings(
testOptions in Test += Tests.Argument(TestFrameworks.JUnit),
libraryDependencies ++= Dependencies.benchmark
)