forked from tofu-tf/tofu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
400 lines (350 loc) · 11.5 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 Publish._, Dependencies._
import com.typesafe.sbt.SbtGit.git
moduleName := "tofu"
val libVersion = "0.10.2"
lazy val setMinorVersion = minorVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) => v.toInt
case _ => 0
}
}
lazy val setModuleName = moduleName := { s"tofu-${(publishName or name).value}" }
lazy val defaultSettings = Seq(
scalaVersion := Version.scala213,
setMinorVersion,
setModuleName,
defaultScalacOptions,
scalacWarningConfig,
libraryDependencies ++= Seq(
compilerPlugin(kindProjector),
compilerPlugin(betterMonadicFor),
scalatest,
collectionCompat,
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided
)
) ++ macros ++ simulacrumOptions ++ publishSettings
lazy val higherKindCore = project settings (
defaultSettings,
publishName := "core-higher-kind",
libraryDependencies ++= Seq(catsCore, catsFree, catsTagless),
)
lazy val core = project dependsOn (opticsCore, higherKindCore) settings (
defaultSettings,
publishName := "core",
libraryDependencies ++= Seq(catsCore, catsEffect, catsTagless),
)
lazy val coreCatsMtlInterop = project
.in(file("core/interop/cats-mtl"))
.settings(
defaultSettings,
publishName := "core-cats-mtl",
libraryDependencies += catsMtl
)
.dependsOn(core)
lazy val memo = project
.dependsOn(core, concurrent)
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, catsEffect),
)
lazy val loggingStr = project
.in(file("logging/structured"))
.settings(
publishName := "logging-structured",
defaultSettings,
libraryDependencies ++= Seq(
catsCore,
catsEffect,
circeCore,
tethys,
tethysJackson,
slf4j,
alleycats,
scalatest,
derevo,
catsTagless
),
)
.dependsOn(core, concurrent, data)
lazy val loggingDer = project
.in(file("logging/derivation"))
.dependsOn(loggingStr)
.dependsOn(opticsMacro % "compile->test", derivation % "compile->test")
.settings(
defaultSettings,
libraryDependencies ++= Seq(derevo, magnolia, slf4j),
publishName := "logging-derivation"
)
lazy val loggingLayout = project
.in(file("logging/layout"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, catsEffect, logback, slf4j),
publishName := "logging-layout"
)
.dependsOn(loggingStr)
lazy val loggingUtil = project
.in(file("logging/util"))
.settings(
defaultSettings,
publishName := "logging-util",
libraryDependencies += slf4j,
)
.dependsOn(loggingStr, concurrent)
lazy val loggingShapeless = project
.in(file("logging/interop/shapeless"))
.settings(
defaultSettings,
publishName := "logging-shapeless",
libraryDependencies += shapeless
)
.dependsOn(loggingStr)
lazy val loggingRefined = project
.in(file("logging/interop/refined"))
.settings(
defaultSettings,
publishName := "logging-refined",
libraryDependencies += refined
)
.dependsOn(loggingStr)
lazy val loggingLog4Cats = project
.in(file("logging/interop/log4cats"))
.settings(
defaultSettings,
publishName := "logging-log4cats",
libraryDependencies += log4Cats
)
.dependsOn(loggingStr)
lazy val logging = project
.dependsOn(loggingStr, loggingDer, loggingLayout, loggingUtil, loggingShapeless, loggingRefined, loggingLog4Cats)
.aggregate(loggingStr, loggingDer, loggingLayout, loggingUtil, loggingShapeless, loggingRefined, loggingLog4Cats)
.settings(defaultSettings)
lazy val env = project
.dependsOn(core, memo)
.settings(defaultSettings, libraryDependencies ++= Seq(catsCore, catsEffect, monix))
lazy val observable = project.settings(
defaultSettings,
libraryDependencies ++= Vector(monix, catsEffect),
libraryDependencies += scalatest
)
lazy val concurrent =
project dependsOn (core, data) settings (
defaultSettings,
libraryDependencies ++= Seq(catsEffect, catsTagless),
)
lazy val config = project dependsOn (core, data, opticsCore, concurrent) settings (
defaultSettings,
libraryDependencies ++= Seq(typesafeConfig, magnolia, derevo),
)
lazy val opticsCore = project
.in(file("optics/core"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, alleycats),
publishName := "optics-core"
)
.dependsOn(higherKindCore)
lazy val opticsInterop = project
.in(file("optics/interop"))
.dependsOn(opticsCore)
.settings(defaultSettings, libraryDependencies ++= Vector(monocle, catsCore), publishName := "optics-interop")
lazy val opticsMacro = project
.in(file("optics/macro"))
.dependsOn(opticsCore)
.settings(
defaultSettings,
scalacOptions ~= { opts =>
val suppressed = List(
"unused:params",
"unused:patvars"
)
opts.filterNot(opt => suppressed.exists(opt.contains))
},
publishName := "optics-macro"
)
lazy val enums = project
.dependsOn(loggingStr)
.settings(
defaultSettings,
libraryDependencies ++= Seq(enumeratum)
)
lazy val data =
project
.settings(defaultSettings, libraryDependencies ++= Seq(catsFree))
.dependsOn(core, opticsCore)
lazy val derivation =
project
.settings(
defaultSettings,
libraryDependencies ++= Seq(magnolia, derevo, catsTagless),
publishName := "derivation",
)
.dependsOn(data)
lazy val zioCore =
project
.in(file("zio/core"))
.settings(defaultSettings, libraryDependencies ++= List(zio, zioCats), publishName := "zio-core")
.dependsOn(core, concurrent)
lazy val zioLogging =
project
.in(file("zio/logging"))
.settings(
defaultSettings,
libraryDependencies ++= List(zio, zioCats, slf4j, logback % Test),
publishName := "zio-logging"
)
.dependsOn(loggingStr, loggingDer % "test", zioCore % Test)
lazy val zioInterop = project
.in(file("zio"))
.settings(
publishName := "zio-interop",
defaultSettings
)
.dependsOn(zioCore, zioLogging)
.aggregate(zioCore, zioLogging)
lazy val fs2Interop = project
.in(file("fs2"))
.settings(
publishName := "fs2-interop",
libraryDependencies += fs2,
defaultSettings
)
.dependsOn(concurrent, streams)
lazy val doobie = project
.in(file("doobie"))
.settings(
libraryDependencies ++= List(doobieCore, derevo, monix % Test),
defaultSettings
)
.dependsOn(core, derivation, env % Test, zioInterop % Test)
lazy val streams = project
.in(file("streams"))
.settings(
libraryDependencies ++= List(fs2 % Test),
defaultSettings
)
.dependsOn(core)
lazy val coreModules =
Vector(
higherKindCore,
core,
opticsMacro,
memo,
derivation,
env,
concurrent,
opticsCore,
data,
streams,
coreCatsMtlInterop
)
lazy val commonModules =
Vector(observable, opticsInterop, logging, enums, config, zioInterop, fs2Interop, doobie)
lazy val allModuleRefs = (coreModules ++ commonModules).map(x => x: ProjectReference)
lazy val allModuleDeps = (coreModules ++ commonModules).map(x => x: ClasspathDep[ProjectReference])
lazy val docs = project // new documentation project
.in(file("tofu-docs"))
.settings(
defaultSettings,
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(allModuleDeps: _*)
.enablePlugins(MdocPlugin, DocusaurusPlugin, ScalaUnidocPlugin)
lazy val tofu = project
.in(file("."))
.settings(defaultSettings)
.settings(
libraryDependencies += "tf.tofu" %% "derevo-cats-tagless" % Version.derevo,
libraryDependencies += catsEffect,
)
.aggregate((coreModules ++ commonModules).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 verboseWarnings = "any:wv"
s"-Wconf:$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 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
}
)
lazy val publishSettings = Seq(
organization := "tf.tofu",
publishVersion := libVersion,
publishMavenStyle := true,
versionScheme := Some("semver-spec"),
description := "Opinionated set of tools for functional programming in Scala",
crossScalaVersions := Seq(Version.scala212, Version.scala213),
publishTo := {
if (isSnapshot.value) {
Some(Opts.resolver.sonatypeSnapshots)
} else sonatypePublishToBundle.value
},
credentials ++= ((Path.userHome / ".sbt" / "tofu.credentials") :: Nil)
.filter(_.exists())
.map(Credentials.apply),
version := {
val branch = git.gitCurrentBranch.value
if (branch == "master") publishVersion.value
else s"${publishVersion.value}-$branch-SNAPSHOT"
},
Compile / doc / sources := Seq.empty,
scmInfo := Some(
ScmInfo(
url("https://github.com/TinkoffCreditSystems/tofu"),
"[email protected]:TinkoffCreditSystems/tofu.git"
)
),
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/tofu-tf/tofu")),
developers := List(
Developer("catostrophe", "λoλcat", "[email protected]", url("https://github.com/catostrophe")),
Developer("danslapman", "Daniil Smirnov", "[email protected]", url("https://github.com/danslapman")),
Developer("odomontois", "Oleg Nizhnik", "[email protected]", url("https://github.com/odomontois")),
Developer("oskin1", "Ilya Oskin", "[email protected]", url("https://github.com/oskin1")),
)
)
addCommandAlias("fmt", "all tofu/scalafmtSbt tofu/scalafmtAll")
addCommandAlias("checkfmt", "all tofu/scalafmtSbtCheck tofu/scalafmtCheckAll")