forked from finagle/finch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
400 lines (373 loc) · 12.4 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
import ReleaseTransformations._
import microsites.ExtraMdFileConfig
lazy val buildSettings = Seq(
organization := "com.github.finagle",
scalaVersion := "2.12.7",
crossScalaVersions := Seq("2.11.12", "2.12.7")
)
lazy val twitterVersion = "19.10.0"
lazy val circeVersion = "0.11.2"
lazy val circeIterateeVersion = "0.12.0"
lazy val circeFs2Version = "0.11.0"
lazy val shapelessVersion = "2.3.3"
lazy val catsVersion = "2.0.0"
lazy val argonautVersion = "6.2.3"
lazy val iterateeVersion = "0.18.0"
lazy val refinedVersion = "0.9.10"
lazy val catsEffectVersion = "2.0.0"
lazy val fs2Version = "2.1.0"
lazy val compilerOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Xfuture",
"-Xlint"
)
val testDependencies = Seq(
"org.scalacheck" %% "scalacheck" % "1.14.2",
"org.scalatest" %% "scalatest" % "3.0.7",
"org.typelevel" %% "cats-laws" % catsVersion,
"org.typelevel" %% "discipline" % "0.11.1"
)
val baseSettings = Seq(
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % shapelessVersion,
"org.typelevel" %% "cats-core" % catsVersion,
"com.twitter" %% "finagle-http" % twitterVersion,
scalaOrganization.value % "scala-reflect" % scalaVersion.value,
"org.typelevel" %% "cats-effect" % catsEffectVersion
) ++ testDependencies.map(_ % "test"),
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
scalacOptions ++= compilerOptions ++ (
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, p)) if p >= 11 => Seq("-Ywarn-unused-import")
case _ => Nil
}
),
scalacOptions in (Compile, console) ~= {
_.filterNot(Set("-Ywarn-unused-import"))
},
scalacOptions in (Compile, console) += "-Yrepl-class-based",
fork in Test := true,
javaOptions in ThisBuild ++= Seq("-Xss2048K"),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.10.3" cross CrossVersion.binary)
)
def updateVersionInFile(selectVersion: sbtrelease.Versions => String): ReleaseStep =
ReleaseStep(action = st => {
val newVersion = selectVersion(st.get(ReleaseKeys.versions).get)
import scala.io.Source
import java.io.PrintWriter
// files containing version to update upon release
val filesToUpdate = Seq(
"docs/src/main/tut/index.md"
)
val pattern = """"com.github.finagle" %% "finch-.*" % "(.*)"""".r
filesToUpdate.foreach { fileName =>
val content = Source.fromFile(fileName).getLines.mkString("\n")
val newContent =
pattern.replaceAllIn(content,
m => m.matched.replaceAllLiterally(m.subgroups.head, newVersion))
new PrintWriter(fileName) {
write(newContent); close()
}
val vcs = Project.extract(st).get(releaseVcs).get
vcs.add(fileName).!
}
st
})
lazy val publishSettings = Seq(
publishMavenStyle := true,
publishArtifact := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
pgpSecretRing := file("local.secring.gpg"),
pgpPublicRing := file("local.pubring.gpg"),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseIgnoreUntrackedFiles := true,
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/finagle/finch")),
autoAPIMappings := true,
apiURL := Some(url("https://finagle.github.io/finch/docs/")),
scmInfo := Some(
ScmInfo(
url("https://github.com/finagle/finch"),
"scm:git:[email protected]:finagle/finch.git"
)
),
releaseVersionBump := sbtrelease.Version.Bump.Minor,
releaseProcess := {
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
releaseStepCommandAndRemaining("+clean"),
releaseStepCommandAndRemaining("+test"),
setReleaseVersion,
updateVersionInFile(_._1),
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
},
pomExtra :=
<developers>
<developer>
<id>vkostyukov</id>
<name>Vladimir Kostyukov</name>
<url>http://vkostyukov.net</url>
</developer>
<developer>
<id>travisbrown</id>
<name>Travis Brown</name>
<url>https://meta.plasm.us/</url>
</developer>
<developer>
<id>rpless</id>
<name>Ryan Plessner</name>
<url>https://twitter.com/ryan_plessner</url>
</developer>
<developer>
<id>sergeykolbasov</id>
<name>Sergey Kolbasov</name>
<url>https://twitter.com/sergey_kolbasov</url>
</developer>
</developers>
)
lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val allSettings = baseSettings ++ buildSettings ++ publishSettings
lazy val docSettings = allSettings ++ Seq(
micrositeName := "Finch",
micrositeDescription := "Scala combinator library for building Finagle HTTP services",
micrositeAuthor := "Vladimir Kostyukov",
micrositeHighlightTheme := "atom-one-light",
micrositeHomepage := "https://finagle.github.io/finch/",
micrositeDocumentationUrl := "api",
micrositeGithubOwner := "finagle",
micrositeGithubRepo := "finch",
micrositeBaseUrl := "finch",
micrositeExtraMdFiles := Map(file("CONTRIBUTING.md") -> ExtraMdFileConfig("contributing.md", "docs")),
micrositePalette := Map(
"brand-primary" -> "#3b3c3b",
"brand-secondary" -> "#4c4d4c",
"brand-tertiary" -> "#5d5e5d",
"gray-dark" -> "#48494B",
"gray" -> "#7D7E7D",
"gray-light" -> "#E5E6E5",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), micrositeDocumentationUrl),
ghpagesNoJekyll := false,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-groups",
"-implicits",
"-skip-packages", "scalaz",
"-doc-source-url", scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-doc-root-content", (resourceDirectory.in(Compile).value / "rootdoc.txt").getAbsolutePath
),
scalacOptions ~= {
_.filterNot(Set("-Yno-predef", "-Xlint", "-Ywarn-unused-import"))
},
git.remoteRepo := "[email protected]:finagle/finch.git",
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(benchmarks, jsonTest),
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.svg" | "*.js" | "*.swf" | "*.yml" | "*.md",
siteSubdirName in ScalaUnidoc := "docs"
)
lazy val finch = project.in(file("."))
.settings(moduleName := "finch")
.settings(allSettings)
.settings(noPublish)
.settings(
initialCommands in console :=
"""
|import io.finch._
|import io.finch.circe._
|import io.finch.generic._
|import io.finch.items._
|import com.twitter.util.{Future, Await}
|import com.twitter.concurrent.AsyncStream
|import com.twitter.io.{Buf, Reader}
|import com.twitter.finagle.Service
|import com.twitter.finagle.Http
|import com.twitter.finagle.http.{Request, Response, Status, Version}
|import io.circe._
|import io.circe.generic.auto._
|import shapeless._
""".stripMargin
)
.settings(libraryDependencies ++= Seq(
"io.circe" %% "circe-generic" % circeVersion
))
.aggregate(
core, fs2, iteratee, generic, argonaut, circe, benchmarks, test, jsonTest, examples, refined
)
.dependsOn(core, iteratee, generic, circe)
lazy val core = project
.settings(moduleName := "finchx-core")
.settings(allSettings)
lazy val iteratee = project
.settings(moduleName := "finchx-iteratee")
.settings(allSettings)
.settings(
libraryDependencies ++= Seq(
"io.iteratee" %% "iteratee-core" % iterateeVersion
)
)
.dependsOn(core % "compile->compile;test->test")
lazy val fs2 = project
.settings(moduleName := "finchx-fs2")
.settings(allSettings)
.settings(
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % fs2Version
)
)
.dependsOn(core % "compile->compile;test->test")
lazy val generic = project
.settings(moduleName := "finchx-generic")
.settings(allSettings)
.dependsOn(core % "compile->compile;test->test")
lazy val test = project
.settings(moduleName := "finchx-test")
.settings(allSettings)
.settings(coverageExcludedPackages := "io\\.finch\\.test\\..*")
.settings(libraryDependencies ++= testDependencies)
.dependsOn(core)
lazy val jsonTest = project.in(file("json-test"))
.settings(moduleName := "finchx-json-test")
.settings(allSettings)
.settings(coverageExcludedPackages := "io\\.finch\\.test\\..*")
.settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-jawn" % circeVersion,
"io.circe" %% "circe-iteratee" % circeIterateeVersion
) ++ testDependencies
)
.dependsOn(core, iteratee)
lazy val argonaut = project
.settings(moduleName := "finchx-argonaut")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"io.argonaut" %% "argonaut" % argonautVersion
))
.dependsOn(core, jsonTest % "test")
lazy val circe = project
.settings(moduleName := "finchx-circe")
.settings(allSettings)
.settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-iteratee" % circeIterateeVersion,
"io.circe" %% "circe-fs2" % circeFs2Version,
"io.circe" %% "circe-jawn" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion % "test"
)
)
.dependsOn(core, jsonTest % "test")
lazy val refined = project
.settings(moduleName := "finchx-refined")
.settings(allSettings)
.settings(
libraryDependencies ++= Seq(
"eu.timepit" %% "refined" % refinedVersion,
"eu.timepit" %% "refined-cats" % refinedVersion % "test",
"eu.timepit" %% "refined-scalacheck" % refinedVersion % "test"
)
)
.dependsOn(core % "test->test;compile->compile")
lazy val docs = project
.settings(moduleName := "finchx-docs")
.settings(docSettings)
.settings(noPublish)
.settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-generic" % circeVersion,
"com.twitter" %% "twitter-server" % twitterVersion,
"joda-time" % "joda-time" % "2.9.9",
"org.mockito" % "mockito-all" % "1.10.19"
)
)
.enablePlugins(MicrositesPlugin, ScalaUnidocPlugin)
.dependsOn(core, circe, argonaut, iteratee, refined)
lazy val examples = project
.settings(moduleName := "finchx-examples")
.settings(allSettings)
.settings(noPublish)
.settings(resolvers += "TM" at "https://maven.twttr.com")
.settings(coverageExcludedPackages :=
"""
|io\.finch\.div\..*;
|io\.finch\.todo\..*;
|io\.finch\.wrk\..*;
|io\.finch\.iteratee\..*;
""".stripMargin)
.settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-generic" % circeVersion,
"com.twitter" %% "finagle-stats" % twitterVersion,
"com.twitter" %% "twitter-server" % twitterVersion
)
)
.dependsOn(core, circe, iteratee)
lazy val benchmarks = project
.settings(moduleName := "finchx-benchmarks")
.enablePlugins(JmhPlugin)
.settings(allSettings)
.settings(noPublish)
.settings(libraryDependencies += "io.circe" %% "circe-generic" % circeVersion)
.settings(coverageExcludedPackages := "io\\.finch\\..*;")
.settings(
javaOptions in run ++= Seq(
"-Djava.net.preferIPv4Stack=true",
"-XX:+AggressiveOpts",
"-XX:+UseParNewGC",
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSParallelRemarkEnabled",
"-XX:+CMSClassUnloadingEnabled",
"-XX:ReservedCodeCacheSize=128m",
"-XX:MaxPermSize=1024m",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
"-Xms512M",
"-Xmx2G",
"-server"
)
)
.dependsOn(core, circe)
val validateCommands = List(
"clean",
"scalastyle",
"test:scalastyle",
"compile",
"test:compile",
"coverage",
"test",
"coverageReport",
"coverageAggregate"
)
addCommandAlias("validate", validateCommands.mkString(";", ";", ""))