forked from http4s/http4s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
694 lines (641 loc) · 20.2 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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
import com.typesafe.tools.mima.core._
import explicitdeps.ExplicitDepsPlugin.autoImport.moduleFilterRemoveValue
import org.http4s.sbt.Http4sPlugin._
import org.http4s.sbt.ScaladocApiMapping
import scala.xml.transform.{RewriteRule, RuleTransformer}
// Global settings
ThisBuild / crossScalaVersions := Seq(scala_212, scala_213, scala_3)
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2.")).last
ThisBuild / baseVersion := "0.22"
ThisBuild / publishGithubUser := "rossabaker"
ThisBuild / publishFullName := "Ross A. Baker"
// Temporary until the dust settles on headers
ThisBuild / fatalWarningsInCI := false
// todo remove once salafmt properly supports scala3
ThisBuild / githubWorkflowBuild := Seq(
// scalafmt suspended on headers branch until the dust settles
WorkflowStep
.Sbt(List("scalafmtCheckAll"), name = Some("Check formatting"), cond = Some(s"matrix.scala != '$scala_3' && false")),
WorkflowStep.Sbt(List("headerCheck", "test:headerCheck"), name = Some("Check headers")),
WorkflowStep.Sbt(List("test:compile"), name = Some("Compile")),
WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Check binary compatibility")),
WorkflowStep.Sbt(
List("unusedCompileDependenciesTest"),
name = Some("Check unused compile dependencies"), cond = Some(s"matrix.scala != '$scala_3'")), // todo disable on dotty for now
WorkflowStep.Sbt(List("test"), name = Some("Run tests")),
WorkflowStep.Sbt(List("doc"), name = Some("Build docs"), cond = Some(s"matrix.scala != '$scala_3'"))
)
ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
"scalafix",
"Scalafix",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep.Run(
List("cd scalafix", "sbt ci"),
name = Some("Scalafix tests"),
cond = Some(s"matrix.scala == '$scala_213'")
)
),
scalas = crossScalaVersions.value.toList
))
enablePlugins(SonatypeCiReleasePlugin)
versionIntroduced := Map(
// There is, and will hopefully not be, an 0.22.0. But this hushes
// MiMa for now while we bootstrap Dotty support.
scala_3 -> "0.22.0",
)
lazy val modules: List[ProjectReference] = List(
core,
laws,
testing,
tests,
server,
prometheusMetrics,
client,
dropwizardMetrics,
emberCore,
emberServer,
emberClient,
blazeCore,
blazeServer,
blazeClient,
asyncHttpClient,
jettyClient,
okHttpClient,
servlet,
jetty,
tomcat,
theDsl,
jawn,
boopickle,
circe,
playJson,
scalaXml,
twirl,
scalatags,
bench,
examples,
examplesBlaze,
examplesDocker,
examplesEmber,
examplesJetty,
examplesTomcat,
examplesWar
)
lazy val root = project.in(file("."))
.enablePlugins(NoPublishPlugin)
.settings(
// Root project
name := "http4s",
description := "A minimal, Scala-idiomatic library for HTTP",
startYear := Some(2013),
)
.aggregate(modules: _*)
lazy val core = libraryProject("core")
.enablePlugins(
BuildInfoPlugin,
MimeLoaderPlugin,
)
.settings(
description := "Core http4s library for servers and clients",
startYear := Some(2013),
buildInfoKeys := Seq[BuildInfoKey](
version,
scalaVersion,
BuildInfoKey.map(http4sApiVersion) { case (_, v) => "apiVersion" -> v }
),
buildInfoPackage := organization.value,
libraryDependencies ++= Seq(
caseInsensitive,
catsCore,
catsEffectStd,
catsParse.exclude("org.typelevel", "cats-core_2.13"),
fs2Core,
fs2Io,
ip4sCore,
log4s,
scodecBits,
slf4jApi, // residual dependency from macros
vault,
),
libraryDependencies ++= {
if (isDotty.value) Seq.empty
else Seq(
scalaReflect(scalaVersion.value) % Provided
)
},
unusedCompileDependenciesFilter -= moduleFilter("org.scala-lang", "scala-reflect"),
)
lazy val laws = libraryProject("laws")
.settings(
description := "Instances and laws for testing http4s code",
startYear := Some(2019),
libraryDependencies ++= Seq(
caseInsensitiveTesting,
catsEffect,
catsEffectTestkit,
catsLaws,
disciplineCore,
ip4sTestKit,
scalacheck,
scalacheckEffectMunit,
munitCatsEffect
),
unusedCompileDependenciesFilter -= moduleFilter(organization = "org.typelevel", name = "scalacheck-effect-munit"),
)
.dependsOn(core)
lazy val testing = libraryProject("testing")
.enablePlugins(NoPublishPlugin)
.settings(
description := "Internal utilities for http4s tests",
startYear := Some(2016),
libraryDependencies ++= Seq(
catsEffectLaws,
munitCatsEffect,
munitDiscipline,
scalacheck,
scalacheckEffect,
scalacheckEffectMunit,
).map(_ % Test),
)
.dependsOn(laws)
// Defined outside core/src/test so it can depend on published testing
lazy val tests = libraryProject("tests")
.enablePlugins(NoPublishPlugin)
.settings(
description := "Tests for core project",
startYear := Some(2013),
)
.dependsOn(core, testing % "test->test")
lazy val server = libraryProject("server")
.settings(
description := "Base library for building http4s servers",
startYear := Some(2014),
)
.settings(BuildInfoPlugin.buildInfoScopedSettings(Test))
.settings(BuildInfoPlugin.buildInfoDefaultSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
resourceDirectory in Test,
),
buildInfoPackage := "org.http4s.server.test",
)
.dependsOn(core, testing % "test->test", theDsl % "test->compile")
lazy val prometheusMetrics = libraryProject("prometheus-metrics")
.settings(
description := "Support for Prometheus Metrics",
startYear := Some(2018),
libraryDependencies ++= Seq(
prometheusClient,
prometheusCommon,
prometheusHotspot,
),
)
.dependsOn(
core % "compile->compile",
theDsl % "test->compile",
testing % "test->test",
server % "test->compile",
client % "test->compile"
)
lazy val client = libraryProject("client")
.settings(
description := "Base library for building http4s clients",
startYear := Some(2014),
libraryDependencies ++= Seq(
jettyServlet % Test,
)
)
.dependsOn(
core,
testing % "test->test",
server % "test->compile",
theDsl % "test->compile")
lazy val dropwizardMetrics = libraryProject("dropwizard-metrics")
.settings(
description := "Support for Dropwizard Metrics",
startYear := Some(2018),
libraryDependencies ++= Seq(
dropwizardMetricsCore,
dropwizardMetricsJson,
jacksonDatabind,
))
.dependsOn(
core % "compile->compile",
testing % "test->test",
theDsl % "test->compile",
client % "test->compile",
server % "test->compile"
)
lazy val emberCore = libraryProject("ember-core")
.settings(
description := "Base library for ember http4s clients and servers",
startYear := Some(2019),
unusedCompileDependenciesFilter -= moduleFilter("io.chrisdavenport", "log4cats-core"),
libraryDependencies ++= Seq(
log4catsTesting % Test,
),
)
.dependsOn(core, testing % "test->test")
lazy val emberServer = libraryProject("ember-server")
.settings(
description := "ember implementation for http4s servers",
startYear := Some(2019),
libraryDependencies ++= Seq(
log4catsSlf4j,
),
)
.dependsOn(emberCore % "compile;test->test", server % "compile;test->test", emberClient % "test->compile")
lazy val emberClient = libraryProject("ember-client")
.settings(
description := "ember implementation for http4s clients",
startYear := Some(2019),
libraryDependencies ++= Seq(
keypool,
log4catsSlf4j,
),
)
.dependsOn(emberCore % "compile;test->test", client % "compile;test->test")
lazy val blazeCore = libraryProject("blaze-core")
.settings(
description := "Base library for binding blaze to http4s clients and servers",
startYear := Some(2014),
libraryDependencies ++= Seq(
blazeHttp,
)
)
.dependsOn(core, testing % "test->test")
lazy val blazeServer = libraryProject("blaze-server")
.settings(
description := "blaze implementation for http4s servers",
startYear := Some(2014),
mimaBinaryIssueFilters ++= Seq(
// privat constructor with new parameter
ProblemFilters.exclude[DirectMissingMethodProblem]("org.http4s.server.blaze.BlazeServerBuilder.this")
)
)
.dependsOn(blazeCore % "compile;test->test", server % "compile;test->test")
lazy val blazeClient = libraryProject("blaze-client")
.settings(
description := "blaze implementation for http4s clients",
startYear := Some(2014),
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("org.http4s.client.blaze.Http1Connection.reset"),
ProblemFilters.exclude[MissingClassProblem]("org.http4s.client.blaze.Http1Connection$Running$"),
),
)
.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",
startYear := Some(2016),
libraryDependencies ++= Seq(
Http4sPlugin.asyncHttpClient,
fs2ReactiveStreams,
nettyBuffer,
nettyCodecHttp,
reactiveStreams,
)
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val jettyClient = libraryProject("jetty-client")
.settings(
description := "jetty implementation for http4s clients",
startYear := Some(2018),
libraryDependencies ++= Seq(
Http4sPlugin.jettyClient,
jettyHttp,
jettyUtil,
),
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val okHttpClient = libraryProject("okhttp-client")
.settings(
description := "okhttp implementation for http4s clients",
startYear := Some(2018),
libraryDependencies ++= Seq(
Http4sPlugin.okhttp,
okio,
),
)
.dependsOn(core, testing % "test->test", client % "compile;test->test")
lazy val servlet = libraryProject("servlet")
.settings(
description := "Portable servlet implementation for http4s servers",
startYear := Some(2013),
libraryDependencies ++= Seq(
javaxServletApi % Provided,
jettyServer % Test,
jettyServlet % Test,
),
)
.dependsOn(server % "compile;test->test")
lazy val jetty = libraryProject("jetty")
.settings(
description := "Jetty implementation for http4s servers",
startYear := Some(2014),
libraryDependencies ++= Seq(
jettyHttp2Server,
jettyServer,
jettyServlet,
jettyUtil,
)
)
.dependsOn(servlet % "compile;test->test", theDsl % "test->test")
lazy val tomcat = libraryProject("tomcat")
.settings(
description := "Tomcat implementation for http4s servers",
startYear := Some(2014),
libraryDependencies ++= Seq(
tomcatCatalina,
tomcatCoyote,
tomcatUtilScan,
)
)
.dependsOn(servlet % "compile;test->test")
// `dsl` name conflicts with modern SBT
lazy val theDsl = libraryProject("dsl")
.settings(
description := "Simple DSL for writing http4s services",
startYear := Some(2013),
)
.dependsOn(core, testing % "test->test")
lazy val jawn = libraryProject("jawn")
.settings(
description := "Base library to parse JSON to various ASTs for http4s",
startYear := Some(2014),
libraryDependencies ++= Seq(
jawnFs2,
jawnParser,
)
)
.dependsOn(core, testing % "test->test")
lazy val boopickle = libraryProject("boopickle")
.settings(
description := "Provides Boopickle codecs for http4s",
startYear := Some(2018),
libraryDependencies ++= Seq(
Http4sPlugin.boopickle.withDottyCompat(scalaVersion.value),
),
skip in compile := isDotty.value,
skip in publish := isDotty.value
)
.dependsOn(core, testing % "test->test")
lazy val circe = libraryProject("circe")
.settings(
description := "Provides Circe codecs for http4s",
startYear := Some(2015),
libraryDependencies ++= Seq(
circeCore,
circeJawn,
circeTesting % Test
)
)
.dependsOn(core, testing % "test->test", jawn % "compile;test->test")
lazy val playJson = libraryProject("play-json")
.settings(
description := "Provides Play json codecs for http4s",
startYear := Some(2018),
libraryDependencies ++= Seq(
// jawnPlay,
Http4sPlugin.playJson,
),
)
.dependsOn(jawn % "compile;test->test")
lazy val scalaXml = libraryProject("scala-xml")
.settings(
description := "Provides scala-xml codecs for http4s",
startYear := Some(2014),
libraryDependencies ++= Seq(
Http4sPlugin.scalaXml,
),
)
.dependsOn(core, testing % "test->test")
lazy val twirl = http4sProject("twirl")
.settings(
description := "Twirl template support for http4s",
startYear := Some(2014),
TwirlKeys.templateImports := Nil,
libraryDependencies := {
libraryDependencies.value.map {
case module if module.name == "twirl-api" =>
module.withDottyCompat(scalaVersion.value)
case module => module
}
},
skip in publish := isDotty.value
)
.enablePlugins(SbtTwirl)
.dependsOn(core, testing % "test->test")
lazy val scalatags = http4sProject("scalatags")
.settings(
description := "Scalatags template support for http4s",
startYear := Some(2018),
libraryDependencies ++= Seq(
scalatagsApi.withDottyCompat(scalaVersion.value),
),
skip in publish := isDotty.value
)
.dependsOn(core, testing % "test->test")
lazy val bench = http4sProject("bench")
.enablePlugins(JmhPlugin)
.enablePlugins(NoPublishPlugin)
.settings(
description := "Benchmarks for http4s",
startYear := Some(2015),
libraryDependencies += circeParser,
undeclaredCompileDependenciesTest := {},
unusedCompileDependenciesTest := {},
)
.dependsOn(core, circe)
lazy val docs = http4sProject("docs")
.enablePlugins(
GhpagesPlugin,
HugoPlugin,
NoPublishPlugin,
ScalaUnidocPlugin,
MdocPlugin
)
.settings(docsProjectSettings)
.settings(
libraryDependencies ++= Seq(
circeGeneric,
circeLiteral,
cryptobits
),
description := "Documentation for http4s",
startYear := Some(2013),
autoAPIMappings := true,
ScalaUnidoc / unidoc / unidocProjectFilter := inAnyProject --
inProjects( // TODO would be nice if these could be introspected from noPublishSettings
bench,
examples,
examplesBlaze,
examplesDocker,
examplesJetty,
examplesTomcat,
examplesWar
),
mdocIn := (sourceDirectory in Compile).value / "mdoc",
makeSite := makeSite.dependsOn(mdoc.toTask(""), http4sBuildData).value,
fatalWarningsInCI := false,
Hugo / baseURL := {
val docsPrefix = extractDocsPrefix(version.value)
if (isCi.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) <- (ScalaUnidoc / packageDoc / mappings).value)
yield (f, s"$docsPrefix/api/$d")
},
ghpagesCleanSite / includeFilter := {
new FileFilter {
val docsPrefix = extractDocsPrefix(version.value)
def accept(f: File) =
f.getCanonicalPath.startsWith(
(ghpagesRepository.value / s"${docsPrefix}").getCanonicalPath)
}
},
apiMappings ++= {
ScaladocApiMapping.mappings(
(ScalaUnidoc / unidoc / unidocAllClasspaths).value, scalaBinaryVersion.value
)
}
)
.dependsOn(client, core, theDsl, blazeServer, blazeClient, circe, dropwizardMetrics, prometheusMetrics)
lazy val website = http4sProject("website")
.enablePlugins(HugoPlugin, GhpagesPlugin, NoPublishPlugin)
.settings(docsProjectSettings)
.settings(
description := "Common area of http4s.org",
startYear := Some(2013),
Hugo / baseURL := {
if (isCi.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,
ghpagesCleanSite / excludeFilter :=
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(NoPublishPlugin)
.settings(
description := "Common code for http4s examples",
startYear := Some(2013),
libraryDependencies ++= Seq(
circeGeneric % Runtime,
logbackClassic % Runtime
),
// todo enable when twirl supports dotty TwirlKeys.templateImports := Nil,
)
.dependsOn(server, dropwizardMetrics, theDsl, circe, scalaXml/*, twirl*/)
// todo enable when twirl supports dotty .enablePlugins(SbtTwirl)
lazy val examplesBlaze = exampleProject("examples-blaze")
.enablePlugins(AlpnBootPlugin)
.settings(Revolver.settings)
.settings(
description := "Examples of http4s server and clients on blaze",
startYear := Some(2013),
fork := true,
libraryDependencies ++= Seq(
circeGeneric,
),
)
.dependsOn(blazeServer, blazeClient)
lazy val examplesEmber = exampleProject("examples-ember")
.settings(Revolver.settings)
.settings(
description := "Examples of http4s server and clients on blaze",
startYear := Some(2020),
fork := true,
)
.dependsOn(emberServer, emberClient)
lazy val examplesDocker = http4sProject("examples-docker")
.in(file("examples/docker"))
.enablePlugins(JavaAppPackaging, DockerPlugin, NoPublishPlugin)
.settings(
description := "Builds a docker image for a blaze-server",
startYear := Some(2017),
Docker / packageName := "http4s/blaze-server",
Docker / maintainer := "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",
startYear := Some(2014),
fork := true,
reStart / mainClass := 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",
startYear := Some(2014),
fork := true,
reStart / mainClass := 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",
startYear := Some(2014),
fork := true,
libraryDependencies += javaxServletApi % Provided,
Jetty / containerLibs := List(jettyRunner),
)
.dependsOn(servlet)
def http4sProject(name: String) =
Project(name, file(name))
.settings(commonSettings)
.settings(
moduleName := s"http4s-$name",
testFrameworks += new TestFramework("munit.Framework"),
initCommands()
)
.enablePlugins(Http4sPlugin)
def libraryProject(name: String) = http4sProject(name)
def exampleProject(name: String) =
http4sProject(name)
.in(file(name.replace("examples-", "examples/")))
.enablePlugins(NoPublishPlugin)
.settings(libraryDependencies += logbackClassic % Runtime)
.dependsOn(examples)
lazy val commonSettings = Seq(
Compile / doc / scalacOptions += "-no-link-warnings",
libraryDependencies ++= Seq(
catsLaws,
logbackClassic,
scalacheck,
).map(_ % Test),
apiURL := Some(url(s"https://http4s.org/v${baseVersion.value}/api")),
)
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")