-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sbt
475 lines (416 loc) · 16.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
/*
* Copyright 2016-2020 Daniel Urban and contributors listed in AUTHORS
* Copyright 2020 Nokia
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
lazy val core = project
.settings(name := "seals-core")
.settings(commonSettings)
.settings(coreSettings)
.settings(macroSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(macros)
lazy val doc = project
.settings(name := "seals-doc")
.settings(commonSettings)
.settings(noPublishSettings)
.settings(scalacOptions -= "-Xfatal-warnings")
.settings(scalacOptions -= "-Werror")
.enablePlugins(MdocPlugin)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core)
lazy val macros = project
.settings(name := "seals-macros")
.settings(commonSettings)
.settings(macrosSettings)
.settings(macroSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
lazy val laws = project
.settings(name := "seals-laws")
.settings(commonSettings)
.settings(lawsSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core)
lazy val tests = project
.settings(name := "seals-tests")
.settings(commonSettings)
.settings(noPublishSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, laws % "test->test;compile->compile")
lazy val checker = project
.settings(name := "seals-checker")
.settings(commonSettings)
.settings(checkerSettings)
.settings(macroSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, circe)
lazy val plugin = project
.settings(name := "seals-plugin")
.enablePlugins(BuildInfoPlugin)
.enablePlugins(ScriptedPlugin)
.settings(commonSettings)
.settings(pluginSettings)
.settings(scriptedDependencies := {
scriptedDependencies.value
// workaround for https://github.com/sbt/sbt/issues/3248
(checker / publishLocal).value
(core / publishLocal).value
(circe / publishLocal).value
(macros / publishLocal).value
(scodec / publishLocal).value // due to the scripted test "seals-plugin / example"
})
lazy val circe = project
.settings(name := s"seals-circe")
.settings(commonSettings)
.settings(circeSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, laws % "test->test", tests % "test->test")
lazy val scodec = project
.settings(name := s"seals-scodec")
.settings(commonSettings)
.settings(scodecSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, laws % "test->test", tests % "test->test")
lazy val refined = project
.settings(name := s"seals-refined")
.settings(commonSettings)
.settings(refinedSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, laws % "test->test", tests % "test->test")
lazy val seals = project.in(file("."))
.settings(name := "seals")
.settings(commonSettings)
.settings(noPublishSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.aggregate(core, macros, laws, tests, checker, circe, scodec, refined) // Note: `plugin` is intentionally missing
lazy val consts = new {
val githubOrg = "durban"
val githubProject = "seals"
val additionalFiles = Seq("LICENSE.txt", "NOTICE.txt", "AUTHORS")
}
lazy val commonSettings: Seq[Setting[_]] = Seq[Setting[_]](
scalaVersion := "2.13.4",
crossScalaVersions := Seq(scalaVersion.value, "2.12.12"),
scalaOrganization := "org.scala-lang",
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-encoding", "UTF-8",
"-language:higherKinds,experimental.macros",
"-Xmigration:2.13.4",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
// TODO: set -sourcepath and -doc-source-url
// TODO: probably also set autoAPIMappings and apiURL
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) =>
Seq(
"-Xfatal-warnings",
"-Xlint:-unused,_",
"-Ypartial-unification",
"-Yno-adapted-args",
)
case _ =>
Seq(
"-Werror",
"-Wunused:_",
"-Wmacros:after",
"-Wvalue-discard",
"-Xlint:-unused,-byname-implicit,_",
)
}
},
scalacOptions in (Compile, console) ~= { _.filterNot("-Ywarn-unused-import" == _).filterNot("-Ywarn-unused:imports" == _) },
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.2" cross CrossVersion.full),
// We need both of these, due to https://github.com/scalastyle/scalastyle-sbt-plugin/issues/44
scalastyleConfig in Test := (baseDirectory in ThisBuild).value / "scalastyle-test-config.xml",
scalastyleConfig in scalastyle := (baseDirectory in ThisBuild).value / "scalastyle-test-config.xml",
libraryDependencies ++= Seq(
Seq(
dependencies.cats,
dependencies.shapeless
),
(dependencies.test ++ dependencies.circe).map(_ % "test-internal")
).flatten,
organization := "dev.tauri",
organizationHomepage := Some(url("https://tauri.dev")),
homepage := Some(url(s"https://github.com/${consts.githubOrg}/${consts.githubProject}")),
scmInfo := Some(ScmInfo(
url(s"https://github.com/${consts.githubOrg}/${consts.githubProject}"),
s"scm:git@github.com:${consts.githubOrg}/${consts.githubProject}.git"
)),
developers += Developer(
id = "durban",
name = "Daniel Urban",
email = "urban.dani@gmail.com",
url = url("https://github.com/durban")
),
licenses := Seq("Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt"))
) ++ inConfig(Compile)(
inTask(packageBin)(extraPackagingSettings) ++
inTask(packageSrc)(extraPackagingSettings) ++
inTask(packageDoc)(extraPackagingSettings)
) ++ publishSettings
lazy val extraPackagingSettings = Seq[Setting[_]](
mappings ++= consts.additionalFiles map { f =>
((baseDirectory in ThisBuild).value / f) -> f
},
packageOptions += Package.ManifestAttributes(java.util.jar.Attributes.Name.SEALED -> "true")
)
lazy val publishSettings = Seq[Setting[_]](
publishMavenStyle := true,
publishArtifact in Compile := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
publishTo := {
if (isSnapshot.value) Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
else Some("staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
},
releaseCrossBuild := true,
releaseVcsSign := true,
releasePublishArtifactsAction := com.typesafe.sbt.pgp.PgpKeys.publishSigned.value,
releaseProcess := {
import ReleaseTransformations._
Seq[ReleaseStep](
releaseStepCommandAndRemaining("clean"),
checkSnapshotDependencies,
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("plugin/clean"), // workaround for https://github.com/sbt/sbt-buildinfo/issues/108
releaseStepCommandAndRemaining("plugin/publishSigned"),
publishArtifacts,
setNextVersion,
commitNextVersion
)
},
useGpg := true,
useGpgAgent := true,
com.typesafe.sbt.pgp.PgpKeys.gpgCommand in Global := "gpg2"
)
lazy val noPublishSettings = Seq[Setting[_]](
skip in publish := true,
publishArtifact in Compile := false,
publishMavenStyle := false
)
lazy val coreSettings = Seq[Setting[_]](
libraryDependencies += dependencies.scodecBits,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.12.")) {
List(dependencies.collectionCompat)
} else {
List()
}
}
)
lazy val macrosSettings = Seq[Setting[_]](
libraryDependencies += dependencies.shapeless % "test-internal"
)
lazy val lawsSettings = Seq[Setting[_]](
libraryDependencies ++= dependencies.laws
)
lazy val checkerSettings = Seq[Setting[_]](
libraryDependencies += scalaOrganization.value % "scala-compiler" % scalaVersion.value
)
lazy val macroSettings = Seq[Setting[_]](
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.12.")) {
List(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
} else {
List()
}
},
scalacOptions ++= {
if (scalaVersion.value.startsWith("2.12.")) {
List()
} else {
List("-Ymacro-annotations")
}
}
)
lazy val pluginSettings = Seq[Setting[_]](
sbtPlugin := true,
scalaVersion := "2.12.12",
crossScalaVersions := Seq(scalaVersion.value),
scalaOrganization := "org.scala-lang",
libraryDependencies += Defaults.sbtPluginExtra(
dependencies.sbtMima,
(sbtBinaryVersion in pluginCrossBuild).value,
(scalaBinaryVersion in update).value
),
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "dev.tauri.seals.plugin",
releaseCrossBuild := false,
scriptedLaunchOpts ++= Seq("-Dplugin.version=" + version.value, "-Xmx1024M"),
scriptedBufferLog := false
)
lazy val circeSettings = Seq[Setting[_]](
libraryDependencies ++= dependencies.circe,
libraryDependencies += dependencies.circeTesting % "test-internal"
)
lazy val scodecSettings = Seq[Setting[_]](
libraryDependencies ++= dependencies.scodec
)
lazy val refinedSettings = Seq[Setting[_]](
libraryDependencies ++= Seq(
dependencies.refined,
scalaOrganization.value % "scala-compiler" % scalaVersion.value % "test-internal"
)
)
lazy val dependencies = new {
val catsVersion = "2.3.0"
val circeVersion = "0.14.0-M1"
val shapeless = "com.chuusai" %% "shapeless" % "2.3.3"
val cats = "org.typelevel" %% "cats-core" % catsVersion
val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.1"
val circe = Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion
)
val circeTesting = "io.circe" %% "circe-testing" % circeVersion
val scodecBits = "org.scodec" %% "scodec-bits" % "1.1.22"
val scodecCats = "org.scodec" %% "scodec-cats" % "1.1.0-M3"
val scodec = Seq(
scodecBits,
"org.scodec" %% "scodec-core" % "1.11.7",
"org.scodec" %% "scodec-stream" % "2.0.0",
scodecCats
)
val refined = "eu.timepit" %% "refined" % "0.9.19"
val laws = Seq(
scodecCats,
"org.typelevel" %% "cats-laws" % catsVersion,
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.5"
)
val test = Seq(
"org.scalatest" %% "scalatest" % "3.1.4",
"org.typelevel" %% "discipline-scalatest" % "1.0.0-RC4"
)
val sbtMima = "com.typesafe" % "sbt-mima-plugin" % "0.8.1"
}
addCommandAlias("testAll", ";test;examples/test")
addCommandAlias("scalastyleAll", ";scalastyle;test:scalastyle;examples/scalastyle;examples/test:scalastyle")
addCommandAlias("mdocAll", "doc/mdoc")
addCommandAlias("doAll", ";testAll;scalastyleAll;mdocAll;publishLocal")
addCommandAlias("doPlugin", ";plugin/clean;plugin/test;plugin/scalastyle;plugin/test:scalastyle;plugin/scripted")
addCommandAlias("validate", ";clean;+ doAll;doPlugin;reload")
//////////////////////
/// Examples ///
//////////////////////
lazy val examples = project.in(file("examples"))
.settings(name := "seals-examples")
.settings(exampleSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.aggregate(exInvariant, exMessaging, exStreaming, exLib)
lazy val exInvariant = project.in(file("examples/invariant"))
.settings(name := "seals-examples-invariant")
.settings(exampleSettings)
.settings(libraryDependencies += exampleDependencies.spire)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, circe)
lazy val exMessaging = project.in(file("examples/messaging"))
.settings(name := "seals-examples-messaging")
.settings(exampleSettings)
.settings(libraryDependencies ++= (exampleDependencies.http4s :+ exampleDependencies.catsEffect))
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, circe)
lazy val exStreaming = project.in(file("examples/streaming"))
.settings(name := "seals-examples-streaming")
.settings(exampleSettings)
.settings(libraryDependencies ++= exampleDependencies.fs2)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, scodec)
lazy val exLib = project.in(file("examples/lib"))
.settings(name := "seals-examples-lib")
.settings(exampleSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.aggregate(exLibProto, exLibServer, exLibClient)
lazy val exLibProto = project.in(file("examples/lib/proto"))
.settings(name := "seals-examples-lib-proto")
.settings(exampleSettings)
.settings(macroSettings)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core)
lazy val exLibServer = project.in(file("examples/lib/server"))
.settings(name := "seals-examples-lib-server")
.settings(exampleSettings)
.settings(libraryDependencies ++= exampleDependencies.fs2)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, scodec, exLibProto)
lazy val exLibClient = project.in(file("examples/lib/client"))
.settings(name := "seals-examples-lib-client")
.settings(exampleSettings)
.settings(libraryDependencies ++= exampleDependencies.akka)
.disablePlugins(ScriptedPlugin) // workaround for https://github.com/sbt/sbt/issues/3514
.dependsOn(core, scodec, exLibProto, exLibServer % "test->compile;test->test")
lazy val exampleSettings = Seq(
scalaVersion := "2.13.4",
crossScalaVersions := Seq(scalaVersion.value, "2.12.12"),
scalaOrganization := "org.scala-lang",
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-encoding", "UTF-8",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Ywarn-unused:imports",
"-Xmigration:2.13.4"
),
scalacOptions ++= {
if (scalaVersion.value.startsWith("2.12.")) List(
"-Yno-adapted-args",
"-Xlint:_"
) else List(
"-Xlint:-byname-implicit,_"
)
},
scalacOptions in (Compile, console) ~= { _.filterNot("-Ywarn-unused-import" == _) },
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
libraryDependencies ++= dependencies.test.map(_ % "test-internal"),
// We need all three, due to https://github.com/scalastyle/scalastyle-sbt-plugin/issues/44
scalastyleConfig in Compile := (baseDirectory in ThisBuild).value / "scalastyle-test-config.xml",
scalastyleConfig in Test := (baseDirectory in ThisBuild).value / "scalastyle-test-config.xml",
scalastyleConfig in scalastyle := (baseDirectory in ThisBuild).value / "scalastyle-test-config.xml",
publishArtifact := false
)
lazy val exampleDependencies = new {
val http4sVersion = "0.21.14"
val fs2Version = "2.4.6"
val http4s = Seq(
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.http4s" %% "http4s-circe" % http4sVersion,
"org.http4s" %% "http4s-blaze-server" % http4sVersion,
"org.http4s" %% "http4s-blaze-client" % http4sVersion,
"org.slf4j" % "slf4j-simple" % "1.7.25"
)
val spire = "org.typelevel" %% "spire" % "0.17.0"
val fs2 = Seq(
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-io" % fs2Version
)
val catsEffect = "org.typelevel" %% "cats-effect" % "2.3.0"
val akka = Seq(
"com.typesafe.akka" %% "akka-stream" % "2.6.10",
"co.fs2" %% "fs2-reactive-streams" % fs2Version
)
}