-
Notifications
You must be signed in to change notification settings - Fork 263
/
build.sbt
271 lines (254 loc) · 8.28 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
Global / onChangedBuildSource := ReloadOnSourceChanges
Global / excludeLintKeys += scalacOptions
// All Twitter library releases are date versioned as YY.MM.patch
val releaseVersion = "24.8.0-SNAPSHOT"
val logbackVersion = "1.2.11"
val opencensusVersion = "0.19.1"
val slf4jVersion = "1.7.30"
def util(which: String) = "com.twitter" %% ("util-" + which) % releaseVersion
def finagle(which: String) = "com.twitter" %% ("finagle-" + which) % releaseVersion
lazy val noPublishSettings = Seq(
publish / skip := true
)
def gcJavaOptions: Seq[String] = {
val javaVersion = System.getProperty("java.version")
if (javaVersion.startsWith("1.8")) {
jdk8GcJavaOptions
} else {
jdk11GcJavaOptions
}
}
def jdk8GcJavaOptions: Seq[String] = {
Seq(
"-XX:+UseParNewGC",
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSParallelRemarkEnabled",
"-XX:+CMSClassUnloadingEnabled",
"-XX:ReservedCodeCacheSize=128m",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
"-Xms512M",
"-Xmx2G"
)
}
def jdk11GcJavaOptions: Seq[String] = {
Seq(
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSParallelRemarkEnabled",
"-XX:+CMSClassUnloadingEnabled",
"-XX:ReservedCodeCacheSize=128m",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
"-Xms512M",
"-Xmx2G"
)
}
def travisTestJavaOptions: Seq[String] = {
// We have some custom configuration for the Travis environment
// https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
val travisBuild = sys.env.getOrElse("TRAVIS", "false").toBoolean
if (travisBuild) {
Seq(
"-DSKIP_FLAKY=true",
"-DSKIP_FLAKY_TRAVIS=true"
)
} else {
Seq(
"-DSKIP_FLAKY=true"
)
}
}
lazy val sharedSettings = Seq(
version := releaseVersion,
organization := "com.twitter",
scalaVersion := "2.13.6",
crossScalaVersions := Seq("2.12.12", "2.13.6"),
Test / fork := true, // We have to fork to get the JavaOptions
libraryDependencies ++= Seq(
// See https://www.scala-sbt.org/0.13/docs/Testing.html#JUnit
"com.novocode" % "junit-interface" % "0.11" % "test",
"org.mockito" % "mockito-all" % "1.9.5" % "test",
"org.scalacheck" %% "scalacheck" % "1.15.4" % "test",
"org.scalatest" %% "scalatest" % "3.1.2" % "test",
"org.scalatestplus" %% "junit-4-12" % "3.1.2.0" % "test",
"org.scalatestplus" %% "mockito-1-10" % "3.1.0.0" % "test",
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.2.0" % "test"
),
ivyXML :=
<dependencies>
<exclude org="com.sun.jmx" module="jmxri" />
<exclude org="com.sun.jdmk" module="jmxtools" />
<exclude org="javax.jms" module="jms" />
</dependencies>,
scalacOptions ++= Seq(
"-target:jvm-1.8",
"-deprecation",
"-unchecked",
"-feature",
"-Xlint",
"-encoding",
"utf8"
),
javacOptions ++= Seq("-Xlint:unchecked", "-source", "1.8", "-target", "1.8"),
doc / javacOptions := Seq("-source", "1.8"),
javaOptions ++= Seq(
"-Djava.net.preferIPv4Stack=true",
"-XX:+AggressiveOpts",
"-server"
),
javaOptions ++= gcJavaOptions,
Test / javaOptions ++= travisTestJavaOptions,
// This is bad news for things like com.twitter.util.Time
Test / parallelExecution := false,
// -a: print stack traces for failing asserts
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a"),
// Sonatype publishing
Test / publishArtifact := false,
pomIncludeRepository := { _ => false },
publishMavenStyle := true,
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
autoAPIMappings := true,
apiURL := Some(url("https://twitter.github.io/twitter-server/docs/")),
pomExtra :=
<url>https://github.com/twitter/twitter-server</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<scm>
<url>[email protected]:twitter/twitter-server.git</url>
<connection>scm:git:[email protected]:twitter/twitter-server.git</connection>
</scm>
<developers>
<developer>
<id>twitter</id>
<name>Twitter Inc.</name>
<url>https://www.twitter.com/</url>
</developer>
</developers>,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
)
lazy val root = (project in file("."))
.enablePlugins(
ScalaUnidocPlugin
)
.settings(sharedSettings)
.settings(noPublishSettings)
.aggregate(
twitterServer,
twitterServerOpenCensus,
twitterServerSlf4jJdk14,
twitterServerSlf4jLog4j12,
twitterServerSlf4jLogbackClassic)
lazy val twitterServer = (project in file("server"))
.enablePlugins(
ScalaUnidocPlugin
)
.settings(name := "twitter-server", moduleName := "twitter-server", sharedSettings)
.settings(
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % slf4jVersion,
finagle("core"),
finagle("http"),
finagle("stats-core"),
finagle("toggle"),
finagle("tunable"),
util("app"),
util("core"),
util("jackson"),
util("jvm"),
util("lint"),
util("registry"),
util("slf4j-api"),
util("slf4j-jul-bridge"),
util("tunable")
)
)
lazy val twitterServerOpenCensus = (project in file("opencensus"))
.enablePlugins(
ScalaUnidocPlugin
)
.settings(
name := "twitter-server-opencensus",
moduleName := "twitter-server-opencensus",
sharedSettings)
.settings(
libraryDependencies ++= Seq(
finagle("core"),
finagle("http"),
"io.opencensus" % "opencensus-api" % opencensusVersion,
"io.opencensus" % "opencensus-contrib-zpages" % opencensusVersion
))
.dependsOn(twitterServer)
lazy val twitterServerSlf4jJdk14 = (project in file("slf4j-jdk14"))
.settings(
name := "twitter-server-slf4j-jdk14",
moduleName := "twitter-server-slf4j-jdk14",
sharedSettings)
.settings(libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % slf4jVersion,
"org.slf4j" % "slf4j-jdk14" % slf4jVersion,
"org.slf4j" % "jcl-over-slf4j" % slf4jVersion,
"org.slf4j" % "log4j-over-slf4j" % slf4jVersion
))
.dependsOn(twitterServer)
lazy val twitterServerSlf4jLog4j12 = (project in file("slf4j-log4j12"))
.settings(
name := "twitter-server-slf4j-log4j12",
moduleName := "twitter-server-slf4j-log4j12",
sharedSettings)
.settings(libraryDependencies ++= Seq(
"log4j" % "log4j" % "1.2.17" % "provided",
"org.slf4j" % "slf4j-api" % slf4jVersion,
"org.slf4j" % "slf4j-log4j12" % slf4jVersion,
"org.slf4j" % "jcl-over-slf4j" % slf4jVersion,
"org.slf4j" % "jul-to-slf4j" % slf4jVersion
))
.dependsOn(twitterServer)
lazy val twitterServerSlf4jLogbackClassic = (project in file("logback-classic"))
.settings(
name := "twitter-server-logback-classic",
moduleName := "twitter-server-logback-classic",
sharedSettings)
.settings(libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % logbackVersion % "provided",
"ch.qos.logback" % "logback-core" % logbackVersion % "provided",
"org.slf4j" % "slf4j-api" % slf4jVersion,
"org.slf4j" % "jcl-over-slf4j" % slf4jVersion,
"org.slf4j" % "jul-to-slf4j" % slf4jVersion,
"org.slf4j" % "log4j-over-slf4j" % slf4jVersion
))
.dependsOn(twitterServer)
lazy val twitterServerDoc = (project in file("doc"))
.enablePlugins(
ScalaUnidocPlugin,
SphinxPlugin
)
.settings(
name := "twitter-server-doc",
sharedSettings,
Seq(
doc / scalacOptions ++= Seq("-doc-title", "TwitterServer", "-doc-version", version.value),
Sphinx / includeFilter := ("*.html" | "*.png" | "*.js" | "*.css" | "*.gif" | "*.txt")
)
)
.configs(DocTest).settings(inConfig(DocTest)(Defaults.testSettings): _*)
.settings(
DocTest / unmanagedSourceDirectories += baseDirectory.value / "src/sphinx/code",
// Make the "test" command run both, test and doctest:test
test := Seq(Test / test, DocTest / test).dependOn.value
)
.dependsOn(twitterServer)
/* Test Configuration for running tests on doc sources */
lazy val DocTest = config("testdoc") extend Test