forked from d2iq-archive/marathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
308 lines (285 loc) · 13.5 KB
/
build.sbt
File metadata and controls
308 lines (285 loc) · 13.5 KB
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import com.amazonaws.auth.{EnvironmentVariableCredentialsProvider, InstanceProfileCredentialsProvider}
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import com.typesafe.sbt.packager.docker.ExecCmd
import mesosphere.raml.RamlGeneratorPlugin
import scalariform.formatter.preferences.{AlignArguments, AlignParameters, AlignSingleLineCaseStatements, CompactControlReadability, DanglingCloseParenthesis, DoubleIndentClassDeclaration, FormatXml, FormattingPreferences, IndentSpaces, IndentWithTabs, MultilineScaladocCommentsStartOnFirstLine, PlaceScaladocAsterisksBeneathSecondAsterisk, Preserve, PreserveSpaceBeforeArguments, SpaceBeforeColon, SpaceInsideBrackets, SpaceInsideParentheses, SpacesAroundMultiImports, SpacesWithinPatternBinders}
lazy val SerialIntegrationTest = config("serial-integration") extend Test
lazy val IntegrationTest = config("integration") extend Test
lazy val UnstableTest = config("unstable") extend Test
lazy val UnstableIntegrationTest = config("unstable-integration") extend Test
def formattingTestArg(target: File) = Tests.Argument("-u", target.getAbsolutePath, "-eDFG")
resolvers += Resolver.sonatypeRepo("snapshots")
addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.17")
/**
* This on load trigger is used to set parameters in teamcity.
* It is only executed within teamcity and can be ignored otherwise.
* It will set values as build and env parameter.
* Those parameters can be used in subsequent build steps and dependent builds.
* TeamCity does this by watching the output of the build it currently performs.
* See: https://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity
*/
lazy val teamCitySetEnvSettings = Seq(
onLoad in Global := {
sys.env.get("TEAMCITY_VERSION") match {
case None => // no-op
case Some(teamcityVersion) =>
def reportParameter(key: String, value: String): Unit = {
//env parameters will be made available as environment variables
println(s"##teamcity[setParameter name='env.SBT_$key' value='$value']")
//system parameters will be made available as teamcity build parameters
println(s"##teamcity[setParameter name='system.sbt.$key' value='$value']")
}
reportParameter("SCALA_VERSION", scalaVersion.value)
reportParameter("PROJECT_VERSION", version.value)
}
(onLoad in Global).value
}
)
lazy val formatSettings = SbtScalariform.scalariformSettings ++ Seq(
ScalariformKeys.preferences := FormattingPreferences()
.setPreference(AlignArguments, false)
.setPreference(AlignParameters, false)
.setPreference(AlignSingleLineCaseStatements, false)
.setPreference(CompactControlReadability, false)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(DanglingCloseParenthesis, Preserve)
.setPreference(FormatXml, true)
.setPreference(IndentSpaces, 2)
.setPreference(IndentWithTabs, false)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, false)
.setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
.setPreference(PreserveSpaceBeforeArguments, true)
.setPreference(SpacesAroundMultiImports, true)
.setPreference(SpaceBeforeColon, false)
.setPreference(SpaceInsideBrackets, false)
.setPreference(SpaceInsideParentheses, false)
.setPreference(SpacesWithinPatternBinders, true)
)
lazy val commonSettings = inConfig(SerialIntegrationTest)(Defaults.testTasks) ++
inConfig(IntegrationTest)(Defaults.testTasks) ++
inConfig(UnstableTest)(Defaults.testTasks) ++
inConfig(UnstableIntegrationTest)(Defaults.testTasks) ++
aspectjSettings ++ Seq(
autoCompilerPlugins := true,
organization := "mesosphere.marathon",
scalaVersion := "2.11.8",
crossScalaVersions := Seq(scalaVersion.value),
scalacOptions in Compile ++= Seq(
"-encoding", "UTF-8",
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xfuture",
"-Xlog-reflective-calls",
"-Xlint",
"-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-import",
//"-Ywarn-value-discard", We should turn this one on soon.
"-Yclosure-elim",
"-Ydead-code"
),
javacOptions in Compile ++= Seq(
"-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-Xlint:deprecation"
),
resolvers ++= Seq(
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/",
"Apache Shapshots" at "https://repository.apache.org/content/repositories/snapshots/",
"Mesosphere Public Repo" at "https://downloads.mesosphere.com/maven"
),
cancelable in Global := true,
publishTo := Some(s3resolver.value(
"Mesosphere Public Repo (S3)",
s3("downloads.mesosphere.io/maven")
)),
s3credentials := new EnvironmentVariableCredentialsProvider() | new InstanceProfileCredentialsProvider(),
testListeners := Seq(new PhabricatorTestReportListener(target.value / "phabricator-test-reports")),
parallelExecution in Test := true,
testForkedParallel in Test := true,
testOptions in Test := Seq(formattingTestArg(target.value / "test-reports"),
Tests.Argument("-l", "mesosphere.marathon.IntegrationTest",
"-l", "mesosphere.marathon.SerialIntegrationTest",
"-l", "mesosphere.marathon.UnstableTest",
"-y", "org.scalatest.WordSpec")),
fork in Test := true,
parallelExecution in UnstableTest := true,
testForkedParallel in UnstableTest := true,
testOptions in UnstableTest := Seq(formattingTestArg(target.value / "test-reports" / "unstable"), Tests.Argument(
"-l", "mesosphere.marathon.IntegrationTest",
"-l", "mesosphere.marathon.SerialIntegrationTest",
"-y", "org.scalatest.WordSpec")),
fork in UnstableTest := true,
fork in SerialIntegrationTest := true,
testOptions in SerialIntegrationTest := Seq(formattingTestArg(target.value / "test-reports" / "serial-integration"),
Tests.Argument(
"-n", "mesosphere.marathon.SerialIntegrationTest",
"-l", "mesosphere.marathon.UnstableTest",
"-y", "org.scalatest.WordSpec")),
parallelExecution in SerialIntegrationTest := false,
testForkedParallel in SerialIntegrationTest := false,
fork in IntegrationTest := true,
testOptions in IntegrationTest := Seq(formattingTestArg(target.value / "test-reports" / "integration"),
Tests.Argument(
"-n", "mesosphere.marathon.IntegrationTest",
"-l", "mesosphere.marathon.SerialIntegrationTest",
"-l", "mesosphere.marathon.UnstableTest",
"-y", "org.scalatest.WordSpec")),
parallelExecution in IntegrationTest := true,
testForkedParallel in IntegrationTest := true,
concurrentRestrictions in IntegrationTest := Seq(Tags.limitAll(math.max(1, java.lang.Runtime.getRuntime.availableProcessors() / 2))),
test in IntegrationTest := {
(test in IntegrationTest).value
(test in SerialIntegrationTest).value
},
fork in UnstableIntegrationTest := true,
testOptions in UnstableIntegrationTest := Seq(formattingTestArg(target.value / "test-reports" / "unstable-integration"),
Tests.Argument(
"-n", "mesosphere.marathon.IntegrationTest",
"-l", "mesosphere.marathon.SerialIntegrationTest",
"-y", "org.scalatest.WordSpec")),
parallelExecution in UnstableIntegrationTest := true,
scapegoatVersion := "1.3.0",
coverageMinimum := 62,
coverageFailOnMinimum := true,
fork in run := true,
AspectjKeys.aspectjVersion in Aspectj := "1.8.10",
AspectjKeys.inputs in Aspectj += compiledClasses.value,
products in Compile := (products in Aspectj).value,
products in Runtime := (products in Aspectj).value,
products in Compile := (products in Aspectj).value,
AspectjKeys.showWeaveInfo := true,
AspectjKeys.verbose := true,
// required for AJC compile time weaving
javacOptions in Compile += "-g",
javaOptions in run ++= (AspectjKeys.weaverOptions in Aspectj).value,
javaOptions in Test ++= (AspectjKeys.weaverOptions in Aspectj).value,
// non-tagged builds use this. Should _always_ end in snapshot.
git.baseVersion := "1.5.0-SNAPSHOT"
)
val aopMerge: sbtassembly.MergeStrategy = new sbtassembly.MergeStrategy {
val name = "aopMerge"
import scala.xml._
import scala.xml.dtd._
def apply(tempDir: File, path: String, files: Seq[File]): Either[String, Seq[(File, String)]] = {
val dt = DocType("aspectj", PublicID("-//AspectJ//DTD//EN", "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"), Nil)
val file = MergeStrategy.createMergeTarget(tempDir, path)
val xmls: Seq[Elem] = files.map(XML.loadFile)
val aspectsChildren: Seq[Node] = xmls.flatMap(_ \\ "aspectj" \ "aspects" \ "_")
val weaverChildren: Seq[Node] = xmls.flatMap(_ \\ "aspectj" \ "weaver" \ "_")
val options: String = xmls.map(x => (x \\ "aspectj" \ "weaver" \ "@options").text).mkString(" ").trim
val weaverAttr = if (options.isEmpty) Null else new UnprefixedAttribute("options", options, Null)
val aspects = new Elem(null, "aspects", Null, TopScope, false, aspectsChildren: _*)
val weaver = new Elem(null, "weaver", weaverAttr, TopScope, false, weaverChildren: _*)
val aspectj = new Elem(null, "aspectj", Null, TopScope, false, aspects, weaver)
XML.save(file.toString, aspectj, "UTF-8", xmlDecl = false, dt)
IO.append(file, IO.Newline.getBytes(IO.defaultCharset))
Right(Seq(file -> path))
}
}
// TODO: Move away from sbt-assembly, favoring sbt-native-packager
lazy val asmSettings = Seq(
assemblyMergeStrategy in assembly := {
case "application.conf" => MergeStrategy.concat
case "META-INF/jersey-module-version" => MergeStrategy.first
case "META-INF/aop.xml" => aopMerge
case "org/apache/hadoop/yarn/util/package-info.class" => MergeStrategy.first
case "org/apache/hadoop/yarn/factories/package-info.class" => MergeStrategy.first
case "org/apache/hadoop/yarn/factory/providers/package-info.class" => MergeStrategy.first
case x => (assemblyMergeStrategy in assembly).value(x)
},
assemblyExcludedJars in assembly := {
val exclude = Set(
"commons-beanutils-1.7.0.jar",
"stax-api-1.0.1.jar",
"commons-beanutils-core-1.8.0.jar",
"servlet-api-2.5.jar",
"jsp-api-2.1.jar"
)
(fullClasspath in assembly).value.filter { x => exclude(x.data.getName) }
},
test in assembly := {}
)
lazy val packagingSettings = Seq(
dockerBaseImage in Docker := "openjdk:8u121-jdk",
dockerExposedPorts in Docker := Seq(8080),
dockerRepository in Docker := Some("mesosphere"),
dockerCommands ++= Seq(
ExecCmd("RUN", "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E56151BF && \\" +
"echo \"deb http://repos.mesosphere.com/debian jessie-testing main\" | tee -a /etc/apt/sources.list.d/mesosphere.list && \\" +
"echo \"deb http://repos.mesosphere.com/debian jessie main\" | tee -a /etc/apt/sources.list.d/mesosphere.list && \\" +
"apt-get update && \\" +
s"apt-get install --no-install-recommends -y --force-yes mesos=${Dependency.V.MesosDebian} && \\" +
"apt-get clean")
)
)
lazy val `plugin-interface` = (project in file("plugin-interface"))
.enablePlugins(GitBranchPrompt, CopyPasteDetector, BasicLintingPlugin)
.configs(SerialIntegrationTest)
.configs(IntegrationTest)
.configs(UnstableTest)
.configs(UnstableIntegrationTest)
.settings(commonSettings : _*)
.settings(formatSettings : _*)
.settings(
name := "plugin-interface",
libraryDependencies ++= Dependencies.pluginInterface
)
lazy val marathon = (project in file("."))
.configs(SerialIntegrationTest)
.configs(IntegrationTest)
.configs(UnstableTest)
.configs(UnstableIntegrationTest)
.enablePlugins(GitBranchPrompt, JavaServerAppPackaging, DockerPlugin,
CopyPasteDetector, RamlGeneratorPlugin, BasicLintingPlugin, GitVersioning)
.dependsOn(`plugin-interface`)
.settings(commonSettings: _*)
.settings(formatSettings: _*)
.settings(teamCitySetEnvSettings: _*)
.settings(asmSettings: _*)
.settings(
unmanagedResourceDirectories in Compile += file("docs/docs/rest-api"),
libraryDependencies ++= Dependencies.marathon,
sourceGenerators in Compile += (ramlGenerate in Compile).taskValue,
scapegoatIgnoredFiles ++= Seq(s"${sourceManaged.value.getPath}/.*"),
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 `mesos-simulation` = (project in file("mesos-simulation"))
.configs(SerialIntegrationTest)
.configs(IntegrationTest)
.configs(UnstableTest)
.configs(UnstableIntegrationTest)
.enablePlugins(GitBranchPrompt, CopyPasteDetector, BasicLintingPlugin)
.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"))
.configs(SerialIntegrationTest)
.configs(IntegrationTest)
.configs(UnstableTest)
.configs(UnstableIntegrationTest)
.enablePlugins(JmhPlugin, GitBranchPrompt, CopyPasteDetector, BasicLintingPlugin)
.settings(commonSettings : _*)
.settings(formatSettings: _*)
.dependsOn(marathon % "compile->compile; test->test")
.settings(
testOptions in Test += Tests.Argument(TestFrameworks.JUnit),
libraryDependencies ++= Dependencies.benchmark,
generatorType in Jmh := "asm"
)