forked from tofu-tf/tofu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
431 lines (379 loc) · 11.7 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
import Publish._, Dependencies._
import com.typesafe.sbt.SbtGit.git
import sbt.ModuleID
lazy val setMinorVersion = minorVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) => v.toInt
case _ => 0
}
}
lazy val defaultSettings = Seq(
scalaVersion := Version.scala213,
crossScalaVersions := Vector(Version.scala212, Version.scala213),
setMinorVersion,
defaultScalacOptions,
scalacWarningConfig,
Compile / doc / scalacOptions -= "-Xfatal-warnings",
libraryDependencies ++= Seq(
compilerPlugin(kindProjector),
compilerPlugin(betterMonadicFor),
scalatest,
collectionCompat,
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided
)
) ++ macros ++ simulacrumOptions
lazy val higherKindCore = project
.in(file("modules/higherKindCore"))
.settings(
defaultSettings,
name := "tofu-core-higher-kind",
libraryDependencies ++= Seq(catsCore, catsFree, catsTagless),
)
lazy val kernel = project
.in(file("modules/kernel"))
.settings(defaultSettings)
.dependsOn(opticsCore, higherKindCore)
.settings(
defaultSettings,
name := "tofu-kernel"
)
lazy val kernelCE2Interop = project
.in(file("modules/kernelCE2Interop"))
.dependsOn(kernel)
.settings(
defaultSettings,
name := "tofu-kernel-ce2-interop",
libraryDependencies += catsEffect2
)
lazy val core = project
.in(file("modules/core"))
.dependsOn(kernel, kernelCE2Interop)
.settings(
defaultSettings,
name := "tofu-core-ce2",
)
lazy val kernelCE3Interop = project
.in(file("modules/kernelCE3Interop"))
.dependsOn(kernel)
.settings(
defaultSettings,
name := "tofu-kernel-ce3-interop",
libraryDependencies += catsEffect3
)
lazy val core3 = project
.in(file("modules/core3"))
.dependsOn(kernel, kernelCE3Interop)
.settings(
defaultSettings,
name := "tofu-core-ce3",
)
lazy val kernelCatsMtlInterop = project
.in(file("modules/kernel/interop/cats-mtl"))
.settings(
defaultSettings,
name := "tofu-kernel-cats-mtl",
libraryDependencies += catsMtl
)
.dependsOn(kernel)
lazy val memo = project
.in(file("modules/memo"))
.dependsOn(core, concurrent)
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, catsEffect2),
name := "tofu-memo"
)
lazy val loggingStr = project
.in(file("modules/logging/structured"))
.settings(
name := "tofu-logging-structured",
defaultSettings,
libraryDependencies ++= Seq(
catsCore,
circeCore,
tethys,
tethysJackson,
slf4j,
alleycats,
scalatest,
derevo,
catsTagless
),
)
.dependsOn(kernel)
lazy val loggingDer = project
.in(file("modules/logging/derivation"))
.dependsOn(loggingStr)
.dependsOn(opticsMacro % "compile->test", derivation % "compile->test")
.settings(
defaultSettings,
libraryDependencies ++= Seq(derevo, magnolia, slf4j),
name := "tofu-logging-derivation"
)
lazy val loggingLayout = project
.in(file("modules/logging/layout"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, logback, slf4j),
name := "tofu-logging-layout"
)
.dependsOn(loggingStr)
lazy val loggingUtil = project
.in(file("modules/logging/util"))
.settings(
defaultSettings,
name := "tofu-logging-util",
libraryDependencies ++= Vector(slf4j, catsEffect2),
)
.dependsOn(loggingStr)
lazy val loggingShapeless = project
.in(file("modules/logging/interop/shapeless"))
.settings(
defaultSettings,
name := "tofu-logging-shapeless",
libraryDependencies += shapeless
)
.dependsOn(loggingStr)
lazy val loggingRefined = project
.in(file("modules/logging/interop/refined"))
.settings(
defaultSettings,
name := "tofu-logging-refined",
libraryDependencies += refined
)
.dependsOn(loggingStr)
lazy val loggingLog4Cats = project
.in(file("modules/logging/interop/log4cats"))
.settings(
defaultSettings,
name := "tofu-logging-log4cats",
libraryDependencies += log4Cats
)
.dependsOn(loggingStr)
lazy val logging = project
.in(file("modules/logging"))
.dependsOn(loggingStr, loggingDer, loggingLayout, loggingUtil, loggingShapeless, loggingRefined, loggingLog4Cats)
.aggregate(loggingStr, loggingDer, loggingLayout, loggingUtil, loggingShapeless, loggingRefined, loggingLog4Cats)
.settings(
defaultSettings,
name := "tofu-logging"
)
lazy val env = project
.in(file("modules/env"))
.dependsOn(core, memo)
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, catsEffect2, monix),
name := "tofu-env"
)
lazy val observable = project
.in(file("modules/observable"))
.settings(
defaultSettings,
libraryDependencies ++= Vector(monix, catsEffect2),
libraryDependencies += scalatest,
name := "tofu-observable",
)
lazy val concurrent =
project
.in(file("modules/concurrent"))
.dependsOn(core, derivation % "compile->test", opticsMacro % "compile->test")
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsEffect2, catsTagless),
libraryDependencies ++= Seq(simulacrum, derevoTagless).map(_ % Test),
name := "tofu-concurrent",
)
lazy val config = project
.in(file("modules/config"))
.dependsOn(core, opticsCore, concurrent)
.settings(
defaultSettings,
libraryDependencies ++= Seq(typesafeConfig, magnolia, derevo),
name := "tofu-config",
)
lazy val opticsCore = project
.in(file("modules/optics/core"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, alleycats),
name := "tofu-optics-core"
)
.dependsOn(higherKindCore)
lazy val opticsInterop = project
.in(file("modules/optics/interop"))
.dependsOn(opticsCore)
.settings(defaultSettings, libraryDependencies ++= Vector(monocle, catsCore), name := "tofu-optics-interop")
lazy val opticsMacro = project
.in(file("modules/optics/macro"))
.dependsOn(opticsCore)
.settings(
defaultSettings,
scalacOptions ~= { opts =>
val suppressed = List(
"unused:params",
"unused:patvars"
)
opts.filterNot(opt => suppressed.exists(opt.contains))
},
name := "tofu-optics-macro"
)
lazy val enums = project
.in(file("modules/enums"))
.dependsOn(loggingStr)
.settings(
defaultSettings,
libraryDependencies ++= Seq(enumeratum),
name := "tofu-enums",
)
lazy val derivation =
project
.in(file("modules/derivation"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(magnolia, derevo, catsTagless),
name := "tofu-derivation",
)
.dependsOn(kernel)
lazy val zioCore =
project
.in(file("modules/zio/core"))
.settings(defaultSettings, libraryDependencies ++= List(zio, zioCats), name := "tofu-zio-core")
.dependsOn(core, concurrent)
lazy val zioLogging =
project
.in(file("modules/zio/logging"))
.settings(
defaultSettings,
libraryDependencies ++= List(zio, zioCats, slf4j, logback % Test),
name := "tofu-zio-logging"
)
.dependsOn(loggingStr, loggingDer % "test", zioCore % Test)
lazy val zioInterop = project
.in(file("modules/zio"))
.settings(
name := "tofu-zio-interop",
defaultSettings
)
.dependsOn(zioCore, zioLogging)
.aggregate(zioCore, zioLogging)
lazy val fs2Interop = project
.in(file("modules/fs2"))
.settings(
name := "tofu-fs2-interop",
libraryDependencies += fs2,
defaultSettings
)
.dependsOn(concurrent, streams)
lazy val doobie = project
.in(file("modules/doobie"))
.settings(
libraryDependencies ++= List(doobieCore, derevo, monix % Test),
defaultSettings,
name := "tofu-doobie",
)
.dependsOn(core, derivation, env % Test, zioInterop % Test)
lazy val streams = project
.in(file("modules/streams"))
.settings(
libraryDependencies ++= List(fs2 % Test),
defaultSettings,
name := "tofu-streams",
)
.dependsOn(kernel)
lazy val coreModules =
Vector(
higherKindCore,
kernel,
kernelCE2Interop,
core,
opticsMacro,
memo,
derivation,
env,
concurrent,
opticsCore,
streams,
kernelCatsMtlInterop
)
lazy val ce3CoreModules = Vector(
kernelCE3Interop,
core3,
)
lazy val commonModules =
Vector(observable, opticsInterop, logging, enums, config, zioInterop, fs2Interop, doobie)
lazy val allModuleRefs = (coreModules ++ commonModules).map(x => x: ProjectReference)
lazy val mainModuleDeps = (coreModules ++ commonModules).map(x => x: ClasspathDep[ProjectReference])
lazy val docs = project // new documentation project
.in(file("tofu-docs"))
.settings(
noPublishSettings,
addCompilerPlugin(simulacrum),
macros,
ScalaUnidoc / unidoc / scalacOptions += "-Ymacro-expand:none",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(allModuleRefs: _*) -- inProjects(opticsMacro),
ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / "website" / "static" / "api",
cleanFiles += (ScalaUnidoc / unidoc / target).value,
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
docusaurusPublishGhpages := docusaurusPublishGhpages.dependsOn(Compile / unidoc).value
)
.dependsOn(mainModuleDeps: _*)
.enablePlugins(MdocPlugin, DocusaurusPlugin, ScalaUnidocPlugin)
lazy val tofu = project
.in(file("."))
.settings(
defaultSettings,
name := "tofu"
)
.aggregate((coreModules ++ commonModules ++ ce3CoreModules :+ docs).map(x => x: ProjectReference): _*)
.dependsOn(coreModules.map(x => x: ClasspathDep[ProjectReference]): _*)
lazy val defaultScalacOptions = scalacOptions := {
val tpolecatOptions = scalacOptions.value
val dropLints = Set(
"-Ywarn-dead-code",
"-Wdead-code" // ignore dead code paths where `Nothing` is involved
)
val opts = tpolecatOptions.filterNot(dropLints)
// drop `-Xfatal-warnings` on dev and 2.12 CI
if (!sys.env.get("CI").contains("true") || (minorVersion.value == 12))
opts.filterNot(Set("-Xfatal-warnings"))
else
opts
}
lazy val scalacWarningConfig = scalacOptions += {
// // ignore unused imports that cannot be removed due to cross-compilation
// val suppressUnusedImports = Seq(
// "scala/tofu/config/typesafe.scala"
// ).map { src =>
// s"src=${scala.util.matching.Regex.quote(src)}&cat=unused-imports:s"
// }.mkString(",")
// print warning category for fine-grained suppressing, e.g. @nowarn("cat=unused-params")
val contextDeprecationInfo = "cat=deprecation&msg=^(.*((Has)|(With)).*)$:silent"
val verboseWarnings = "any:wv"
s"-Wconf:$contextDeprecationInfo,$verboseWarnings"
}
lazy val macros = Seq(
scalacOptions ++= { if (minorVersion.value == 13) Seq("-Ymacro-annotations") else Seq() },
libraryDependencies ++= { if (minorVersion.value == 12) Seq(compilerPlugin(macroParadise)) else Seq() }
)
lazy val noPublishSettings =
defaultSettings ++ Seq(publish := {}, publishArtifact := false, publishTo := None, publish / skip := true)
lazy val simulacrumOptions = Seq(
libraryDependencies += simulacrum % Provided,
pomPostProcess := { node =>
import scala.xml.transform.{RewriteRule, RuleTransformer}
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 == simulacrum.organization) &&
e.child.exists(child => child.label == "artifactId" && child.text.startsWith(s"${simulacrum.name}_")) =>
Nil
case _ => Seq(node)
}
}).transform(node).head
}
)
addCommandAlias("fmt", "all tofu/scalafmtSbt tofu/scalafmtAll")
addCommandAlias("checkfmt", "all tofu/scalafmtSbtCheck tofu/scalafmtCheckAll")
addCommandAlias("preparePR", "scalafmtAll ;scalafmtSbt ;reload; githubWorkflowGenerate; clean; Test / compile")