forked from http4s/http4s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
558 lines (511 loc) · 17 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
import org.http4s.build.Http4sPlugin._
import scala.xml.transform.{RewriteRule, RuleTransformer}
// Global settings
organization in ThisBuild := "org.http4s"
// Root project
name := "http4s"
description := "A minimal, Scala-idiomatic library for HTTP"
enablePlugins(PrivateProjectPlugin)
cancelable in Global := true
lazy val core = libraryProject("core")
.enablePlugins(BuildInfoPlugin)
.settings(
description := "Core http4s library for servers and clients",
buildInfoKeys := Seq[BuildInfoKey](
version,
scalaVersion,
BuildInfoKey.map(http4sApiVersion) { case (_, v) => "apiVersion" -> v }
),
buildInfoPackage := organization.value,
resolvers += "Sonatype OSS Snapshots".at(
"https://oss.sonatype.org/content/repositories/snapshots"),
libraryDependencies ++= Seq(
cats,
fs2Io,
log4s,
parboiled,
vault,
scalaReflect(scalaOrganization.value, scalaVersion.value) % "provided",
scalaCompiler(scalaOrganization.value, scalaVersion.value) % "provided"
),
)
lazy val testing = libraryProject("testing")
.settings(
description := "Instances and laws for testing http4s code",
libraryDependencies ++= Seq(
catsEffectLaws,
scalacheck,
specs2Matcher
),
)
.dependsOn(core)
// Defined outside core/src/test so it can depend on published testing
lazy val tests = libraryProject("tests")
.enablePlugins(PrivateProjectPlugin)
.settings(
description := "Tests for core project",
)
.dependsOn(core, testing % "test->test")
lazy val server = libraryProject("server")
.settings(
description := "Base library for building http4s servers"
)
.dependsOn(core, testing % "test->test", theDsl % "test->compile")
lazy val prometheusMetrics = libraryProject("prometheus-metrics")
.settings(
description := "Support for Prometheus Metrics",
libraryDependencies ++= Seq(
prometheusCommon,
prometheusHotspot,
prometheusClient
),
)
.dependsOn(
core % "compile->compile",
theDsl % "compile->compile",
testing % "test->test",
server % "test->compile",
client % "test->compile"
)
lazy val client = libraryProject("client")
.settings(
description := "Base library for building http4s clients",
libraryDependencies += jettyServlet % "test"
)
.dependsOn(
core,
testing % "test->test",
server % "test->compile",
theDsl % "test->compile",
scalaXml % "test->compile")
lazy val dropwizardMetrics = libraryProject("dropwizard-metrics")
.settings(
description := "Support for Dropwizard Metrics",
libraryDependencies ++= Seq(
dropwizardMetricsCore,
dropwizardMetricsJson
) )
.dependsOn(
core % "compile->compile",
testing % "test->test",
theDsl % "test->compile",
client % "test->compile",
server % "test->compile"
)
lazy val blazeCore = libraryProject("blaze-core")
.settings(
description := "Base library for binding blaze to http4s clients and servers",
libraryDependencies += blaze,
)
.dependsOn(core, testing % "test->test")
lazy val blazeServer = libraryProject("blaze-server")
.settings(
description := "blaze implementation for http4s servers"
)
.dependsOn(blazeCore % "compile;test->test", server % "compile;test->test")
lazy val blazeClient = libraryProject("blaze-client")
.settings(
description := "blaze implementation for http4s clients"
)
.dependsOn(blazeCore % "compile;test->test", client % "compile;test->test")
lazy val asyncHttpClient = libraryProject("async-http-client")
.settings(
description := "async http client implementation for http4s clients",
libraryDependencies ++= Seq(
Http4sPlugin.asyncHttpClient,
fs2ReactiveStreams
)
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val jettyClient = libraryProject("jetty-client")
.settings(
description := "jetty implementation for http4s clients",
libraryDependencies ++= Seq(
Http4sPlugin.jettyClient
),
mimaPreviousArtifacts := Set.empty // remove me once merged
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val okHttpClient = libraryProject("okhttp-client")
.settings(
description := "okhttp implementation for http4s clients",
libraryDependencies ++= Seq(
Http4sPlugin.okhttp
),
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val servlet = libraryProject("servlet")
.settings(
description := "Portable servlet implementation for http4s servers",
libraryDependencies ++= Seq(
javaxServletApi % "provided",
jettyServer % "test",
jettyServlet % "test",
mockito % "test"
),
)
.dependsOn(server % "compile;test->test")
lazy val jetty = libraryProject("jetty")
.settings(
description := "Jetty implementation for http4s servers",
libraryDependencies ++= Seq(
jettyServlet
)
)
.dependsOn(servlet % "compile;test->test", theDsl % "test->test")
lazy val tomcat = libraryProject("tomcat")
.settings(
description := "Tomcat implementation for http4s servers",
libraryDependencies ++= Seq(
tomcatCatalina,
tomcatCoyote
)
)
.dependsOn(servlet % "compile;test->test")
// `dsl` name conflicts with modern SBT
lazy val theDsl = libraryProject("dsl")
.settings(
description := "Simple DSL for writing http4s services"
)
.dependsOn(core, testing % "test->test")
lazy val jawn = libraryProject("jawn")
.settings(
description := "Base library to parse JSON to various ASTs for http4s",
libraryDependencies += jawnFs2
)
.dependsOn(core, testing % "test->test")
lazy val argonaut = libraryProject("argonaut")
.settings(
description := "Provides Argonaut codecs for http4s",
libraryDependencies ++= Seq(
Http4sPlugin.argonaut
)
)
.dependsOn(core, testing % "test->test", jawn % "compile;test->test")
lazy val boopickle = libraryProject("boopickle")
.settings(
description := "Provides Boopickle codecs for http4s",
libraryDependencies ++= Seq(
Http4sPlugin.boopickle
),
)
.dependsOn(core, testing % "test->test")
lazy val circe = libraryProject("circe")
.settings(
description := "Provides Circe codecs for http4s",
libraryDependencies ++= Seq(
circeJawn,
circeTesting % "test"
)
)
.dependsOn(core, testing % "test->test", jawn % "compile;test->test")
lazy val json4s = libraryProject("json4s")
.settings(
description := "Base library for json4s codecs for http4s",
libraryDependencies ++= Seq(
jawnJson4s,
json4sCore
),
)
.dependsOn(jawn % "compile;test->test")
lazy val json4sNative = libraryProject("json4s-native")
.settings(
description := "Provides json4s-native codecs for http4s",
libraryDependencies += Http4sPlugin.json4sNative
)
.dependsOn(json4s % "compile;test->test")
lazy val json4sJackson = libraryProject("json4s-jackson")
.settings(
description := "Provides json4s-jackson codecs for http4s",
libraryDependencies += Http4sPlugin.json4sJackson
)
.dependsOn(json4s % "compile;test->test")
lazy val playJson = libraryProject("play-json")
.settings(
description := "Provides Play json codecs for http4s",
libraryDependencies ++= Seq(
jawnPlay,
Http4sPlugin.playJson
),
)
.dependsOn(jawn % "compile;test->test")
lazy val scalaXml = libraryProject("scala-xml")
.settings(
description := "Provides scala-xml codecs for http4s",
libraryDependencies ++= scalaVersion(VersionNumber(_).numbers match {
case Seq(2, scalaMajor, _*) if scalaMajor >= 11 => Seq(Http4sPlugin.scalaXml)
case _ => Seq.empty
}).value,
)
.dependsOn(core, testing % "test->test")
lazy val twirl = http4sProject("twirl")
.settings(
description := "Twirl template support for http4s",
libraryDependencies += twirlApi,
TwirlKeys.templateImports := Nil
)
.enablePlugins(SbtTwirl)
.dependsOn(core, testing % "test->test")
lazy val scalatags = http4sProject("scalatags")
.settings(
description := "Scalatags template support for http4s",
libraryDependencies += scalatagsApi,
)
.dependsOn(core, testing % "test->test")
lazy val mimedbGenerator = http4sProject("mimedb-generator")
.enablePlugins(PrivateProjectPlugin)
.settings(
description := "MimeDB source code generator",
libraryDependencies ++= Seq(
Http4sPlugin.treeHugger,
Http4sPlugin.circeGeneric
)
)
.dependsOn(blazeClient, circe)
lazy val bench = http4sProject("bench")
.enablePlugins(JmhPlugin)
.enablePlugins(PrivateProjectPlugin)
.settings(
description := "Benchmarks for http4s",
libraryDependencies += circeParser,
)
.dependsOn(core, circe)
lazy val docs = http4sProject("docs")
.enablePlugins(
GhpagesPlugin,
HugoPlugin,
PrivateProjectPlugin,
ScalaUnidocPlugin,
TutPlugin
)
.settings(
libraryDependencies ++= Seq(
circeGeneric,
circeLiteral,
cryptobits
),
description := "Documentation for http4s",
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject --
inProjects( // TODO would be nice if these could be introspected from noPublishSettings
bench,
examples,
examplesBlaze,
examplesDocker,
examplesJetty,
examplesTomcat,
examplesWar,
mimedbGenerator
),
scalacOptions in Tut ~= {
val unwanted = Set("-Ywarn-unused:params", "-Ywarn-unused:imports")
// unused params warnings are disabled due to undefined functions in the doc
_.filterNot(unwanted) :+ "-Xfatal-warnings"
},
scalacOptions in (Compile, doc) ++= {
scmInfo.value match {
case Some(s) =>
val isMaster = git.gitCurrentBranch.value == "master"
val isSnapshot =
git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.isEmpty
val gitHeadCommit = git.gitHeadCommit.value
val v = version.value
val path =
if (isSnapshot && isMaster)
s"${s.browseUrl}/tree/master€{FILE_PATH}.scala"
else if (isSnapshot)
s"${s.browseUrl}/blob/${gitHeadCommit.get}€{FILE_PATH}.scala"
else
s"${s.browseUrl}/blob/v${version}€{FILE_PATH}.scala"
Seq(
"-implicits",
"-doc-source-url",
path,
"-sourcepath",
(baseDirectory in ThisBuild).value.getAbsolutePath
)
case _ => Seq.empty
}
},
scalacOptions in (Compile, doc) -= "-Ywarn-unused:imports",
makeSite := makeSite.dependsOn(tutQuick, http4sBuildData).value,
baseURL in Hugo := {
val docsPrefix = extractDocsPrefix(version.value)
if (isTravisBuild.value) new URI(s"https://http4s.org${docsPrefix}")
else new URI(s"http://127.0.0.1:${previewFixedPort.value.getOrElse(4000)}${docsPrefix}")
},
siteMappings := {
val docsPrefix = extractDocsPrefix(version.value)
for ((f, d) <- siteMappings.value) yield (f, docsPrefix + "/" + d)
},
siteMappings ++= {
val docsPrefix = extractDocsPrefix(version.value)
for ((f, d) <- (mappings in (ScalaUnidoc, packageDoc)).value)
yield (f, s"$docsPrefix/api/$d")
},
includeFilter in ghpagesCleanSite := {
new FileFilter {
val docsPrefix = extractDocsPrefix(version.value)
def accept(f: File) =
f.getCanonicalPath.startsWith(
(ghpagesRepository.value / s"${docsPrefix}").getCanonicalPath)
}
},
)
.dependsOn(client, core, theDsl, blazeServer, blazeClient, circe, dropwizardMetrics, prometheusMetrics)
lazy val website = http4sProject("website")
.enablePlugins(HugoPlugin, GhpagesPlugin, PrivateProjectPlugin)
.settings(
description := "Common area of http4s.org",
baseURL in Hugo := {
if (isTravisBuild.value) new URI(s"https://http4s.org")
else new URI(s"http://127.0.0.1:${previewFixedPort.value.getOrElse(4000)}")
},
makeSite := makeSite.dependsOn(http4sBuildData).value,
// all .md|markdown files go into `content` dir for hugo processing
ghpagesNoJekyll := true,
excludeFilter in ghpagesCleanSite :=
new FileFilter {
val v = ghpagesRepository.value.getCanonicalPath + "/v"
def accept(f: File) =
f.getCanonicalPath.startsWith(v) &&
f.getCanonicalPath.charAt(v.size).isDigit
}
)
lazy val examples = http4sProject("examples")
.enablePlugins(PrivateProjectPlugin)
.settings(
description := "Common code for http4s examples",
libraryDependencies ++= Seq(
circeGeneric,
logbackClassic % "runtime",
jspApi % "runtime" // http://forums.yourkit.com/viewtopic.php?f=2&t=3733
),
TwirlKeys.templateImports := Nil
)
.dependsOn(server, dropwizardMetrics, theDsl, circe, scalaXml, twirl)
.enablePlugins(SbtTwirl)
lazy val examplesBlaze = exampleProject("examples-blaze")
.settings(Revolver.settings)
.settings(
description := "Examples of http4s server and clients on blaze",
fork := true,
libraryDependencies ++= Seq(alpnBoot, dropwizardMetricsJson),
run / javaOptions ++= addAlpnPath((Runtime / managedClasspath).value)
)
.dependsOn(blazeServer, blazeClient)
lazy val examplesDocker = http4sProject("examples-docker")
.in(file("examples/docker"))
.enablePlugins(JavaAppPackaging, DockerPlugin, PrivateProjectPlugin)
.settings(
description := "Builds a docker image for a blaze-server",
packageName in Docker := "http4s/blaze-server",
maintainer in Docker := "http4s",
dockerUpdateLatest := true,
dockerExposedPorts := List(8080),
)
.dependsOn(blazeServer, theDsl)
lazy val examplesJetty = exampleProject("examples-jetty")
.settings(Revolver.settings)
.settings(
description := "Example of http4s server on Jetty",
fork := true,
mainClass in reStart := Some("com.example.http4s.jetty.JettyExample")
)
.dependsOn(jetty)
lazy val examplesTomcat = exampleProject("examples-tomcat")
.settings(Revolver.settings)
.settings(
description := "Example of http4s server on Tomcat",
fork := true,
mainClass in reStart := Some("com.example.http4s.tomcat.TomcatExample")
)
.dependsOn(tomcat)
// Run this with jetty:start
lazy val examplesWar = exampleProject("examples-war")
.enablePlugins(JettyPlugin)
.settings(
description := "Example of a WAR deployment of an http4s service",
fork := true,
libraryDependencies += javaxServletApi % "provided",
containerLibs in Jetty := List(jettyRunner),
)
.dependsOn(servlet)
def http4sProject(name: String) =
Project(name, file(name))
.settings(commonSettings)
.settings(
moduleName := s"http4s-$name",
Test / testOptions += Tests.Argument(TestFrameworks.Specs2, "showtimes", "failtrace"),
initCommands()
)
def libraryProject(name: String) = http4sProject(name)
def exampleProject(name: String) =
http4sProject(name)
.in(file(name.replace("examples-", "examples/")))
.enablePlugins(PrivateProjectPlugin)
.settings(libraryDependencies += logbackClassic % "runtime")
.dependsOn(examples)
lazy val commonSettings = Seq(
http4sJvmTarget := scalaVersion.map {
VersionNumber(_).numbers match {
case Seq(2, 10, _*) => "1.7"
case _ => "1.8"
}
}.value,
Compile / scalacOptions ++= Seq(
s"-target:jvm-${http4sJvmTarget.value}"
),
Compile / doc / scalacOptions += "-no-link-warnings",
javacOptions ++= Seq(
"-source",
http4sJvmTarget.value,
"-target",
http4sJvmTarget.value,
"-Xlint:deprecation",
"-Xlint:unchecked"
),
libraryDependencies ++= Seq(
catsLaws,
catsKernelLaws,
discipline,
logbackClassic,
scalacheck, // 0.13.3 fixes None.get
specs2Core,
specs2MatcherExtra,
specs2Scalacheck
).map(_ % "test"),
// don't include scoverage as a dependency in the pom
// https://github.com/scoverage/sbt-scoverage/issues/153
// this code was copied from https://github.com/mongodb/mongo-spark
pomPostProcess := { (node: xml.Node) =>
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: xml.Elem
if e.label == "dependency" && e.child.exists(
child => child.label == "groupId" && child.text == "org.scoverage") =>
Nil
case _ => Seq(node)
}
}).transform(node).head
},
ivyLoggingLevel := UpdateLogging.Quiet, // This doesn't seem to work? We see this in MiMa
git.remoteRepo := "[email protected]:http4s/http4s.git",
includeFilter in Hugo := (
"*.html" | "*.png" | "*.jpg" | "*.gif" | "*.ico" | "*.svg" |
"*.js" | "*.swf" | "*.json" | "*.md" |
"*.css" | "*.woff" | "*.woff2" | "*.ttf" |
"CNAME" | "_config.yml" | "_redirects"
)
)
def initCommands(additionalImports: String*) =
initialCommands := (List(
"fs2._",
"cats._",
"cats.data._",
"cats.effect._",
"cats.implicits._"
) ++ additionalImports).mkString("import ", ", ", "")
// Everything is driven through release steps and the http4s* variables
// This won't actually release unless on Travis.
addCommandAlias("ci", ";clean ;release with-defaults")