-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbuild.sbt
226 lines (211 loc) · 6.75 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
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import com.amazonaws.services.s3.model.Region
import com.typesafe.sbt.packager
import play.sbt.routes.RoutesKeys
import sbtprotobuf.{ProtobufPlugin => PB}
lazy val projectSettings = baseSettings ++ publishSettings
lazy val writeVersion = taskKey[Unit]("Output version to target folder")
writeVersion := {
val s = streams.value
val file = (target in Compile).value / "version.txt"
IO.write(file, version.value)
s.log.info(s"Wrote version ${version.value} to $file")
}
lazy val packagingSettings = Seq((packageName in Universal) := {
import sys.process._
val shortCommit = ("./version commit" !!).trim
s"${packageName.value}-${version.value}-$shortCommit"
})
lazy val baseSettings = Seq(
version := {
import sys.process._
("./version" !!).trim
},
organization := "dcos",
scalaVersion := "2.12.10",
addCompilerPlugin(scalafixSemanticdb),
crossScalaVersions := Seq(scalaVersion.value),
scalacOptions ++= Seq(
"-Yrangepos", // required by SemanticDB compiler plugin
"-Ywarn-unused", // required by `RemoveUnused` rule
"-encoding",
"UTF-8",
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlog-reflective-calls",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen"
),
scalacOptions in (Compile, doc) ++= Seq(
"-no-link-warnings" // Suppresses problems with Scaladoc @throws links
),
javacOptions in Compile ++= Seq(
"-encoding",
"UTF-8",
"-source",
"1.8",
"-target",
"1.8",
"-Xlint:unchecked",
"-Xlint:deprecation"
),
resolvers ++= Seq(
Resolver.JCenterRepository,
"Mesosphere Public Repo" at "https://downloads.mesosphere.io/maven",
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/",
"emueller-bintray" at "https://dl.bintray.com/emueller/maven"
),
fork in Test := true
)
val excludeSlf4jLog4j12 =
ExclusionRule(organization = "org.slf4j", name = "slf4j-log4j12")
val excludeLog4j = ExclusionRule(organization = "log4j", name = "log4j")
val excludeJCL =
ExclusionRule(organization = "commons-logging", name = "commons-logging")
lazy val publishSettings = Seq(
publishTo := Some(
s3resolver
.value("Mesosphere Public Repo (S3)", s3("downloads.mesosphere.io/maven"))
),
s3credentials := DefaultAWSCredentialsProviderChain.getInstance(),
s3region := Region.US_Standard
)
lazy val nativePackageSettings = Seq(
packager.Keys.bashScriptExtraDefines ++= IO
.readLines(baseDirectory.value / "bin" / "extra.sh")
)
val pbSettings = PB.projectSettings ++ Seq(
(protobufRunProtoc in ProtobufConfig) := (args => com.github.os72.protocjar.Protoc.runProtoc("-v330" +: args.toArray))
)
lazy val metronome = (project in file("."))
.dependsOn(api, jobs)
.aggregate(api, jobs)
.enablePlugins(PlayScala)
.enablePlugins(JavaServerAppPackaging)
.disablePlugins(PlayLayoutPlugin)
.enablePlugins(UniversalDeployPlugin)
.settings(projectSettings)
.settings(nativePackageSettings)
.settings(packagingSettings)
.settings(
libraryDependencies ++= Dependencies.akkaHttp ++
Seq(
Dependencies.macWireMacros,
Dependencies.macWireUtil,
Dependencies.macWireProxy,
Dependencies.Test.scalatest,
Dependencies.Test.usiTestUtils
).map(
_.excludeAll(excludeSlf4jLog4j12)
.excludeAll(excludeLog4j)
.excludeAll(excludeJCL)
)
)
val silencerVersion = "1.1"
addCompilerPlugin("com.github.ghik" %% "silencer-plugin" % silencerVersion)
lazy val api = (project in file("api"))
.enablePlugins(PlayScala)
.disablePlugins(PlayLayoutPlugin)
.dependsOn(jobs % "compile->compile;test->test")
.settings(projectSettings)
.settings(
RoutesKeys.routesImport ++= Seq("dcos.metronome.api.Binders._"),
libraryDependencies ++=
Dependencies.akkaHttp ++ Seq(
Dependencies.playJson,
Dependencies.playWS,
Dependencies.marathonPlugin,
Dependencies.macWireMacros,
Dependencies.macWireUtil,
Dependencies.macWireProxy,
Dependencies.yaml,
Dependencies.cronUtils,
Dependencies.jsonValidate,
Dependencies.iteratees,
Dependencies.playAhcWS,
Dependencies.Test.scalatest,
Dependencies.Test.scalaCheck,
Dependencies.Test.scalatestPlay,
Dependencies.Test.usiTestUtils,
"com.github.ghik" %% "silencer-lib" % silencerVersion % Provided
).map(
_.excludeAll(excludeSlf4jLog4j12)
.excludeAll(excludeLog4j)
.excludeAll(excludeJCL)
)
)
lazy val jobs = (project in file("jobs"))
.enablePlugins(PB)
.settings(
version := {
import sys.process._
("./version" !!).trim
},
projectSettings
)
.settings(pbSettings)
.settings(
libraryDependencies ++= Seq(
Dependencies.asyncAwait,
Dependencies.playJson,
Dependencies.marathon,
Dependencies.marathonPlugin,
Dependencies.macWireMacros,
Dependencies.macWireUtil,
Dependencies.macWireProxy,
Dependencies.cronUtils,
Dependencies.akka,
Dependencies.akkaSlf4j,
Dependencies.caffeine,
Dependencies.usiCommons,
Dependencies.Test.scalatest,
Dependencies.Test.akkaTestKit,
Dependencies.Test.mockito,
Dependencies.Test.scalatest,
Dependencies.Test.scalaCheck,
Dependencies.Test.usiTestUtils
).map(
_.excludeAll(excludeSlf4jLog4j12)
.excludeAll(excludeLog4j)
.excludeAll(excludeJCL)
)
)
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))
)
)
lazy val integration = (project in file("./tests/integration"))
.settings(integrationTestSettings: _*)
.settings(projectSettings: _*)
.settings(
cleanFiles += baseDirectory { base => base / "sandboxes" }.value
)
.dependsOn(metronome % "test->test")