forked from kevin-lee/refined4s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
450 lines (381 loc) · 14.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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
import just.semver.SemVer
import sbtcrossproject.CrossProject
ThisBuild / scalaVersion := props.ProjectScalaVersion
ThisBuild / organization := props.Org
ThisBuild / organizationName := "Kevin's Code"
ThisBuild / testFrameworks ~=
(frameworks => (TestFramework("hedgehog.sbt.Framework") +: frameworks).distinct)
ThisBuild / developers := List(
Developer(
props.GitHubUsername,
"Kevin Lee",
url(s"https://github.com/${props.GitHubUsername}"),
)
)
ThisBuild / homepage := Some(url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}"))
ThisBuild / scmInfo :=
Some(
ScmInfo(
url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}"),
s"[email protected]:${props.GitHubUsername}/${props.RepoName}.git",
)
)
ThisBuild / licenses := props.licenses
ThisBuild / resolvers += props.SonatypeSnapshots
ThisBuild / scalafixDependencies += "com.github.xuwei-k" %% "scalafix-rules" % "0.3.0"
ThisBuild / scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
else
((ThisBuild / baseDirectory).value / ".scalafix-scala2.conf").some
)
ThisBuild / scalafixScalaBinaryVersion := {
val log = sLog.value
val newVersion = if (scalaVersion.value.startsWith("3")) {
(ThisBuild / scalafixScalaBinaryVersion).value
} else {
CrossVersion.binaryScalaVersion(scalaVersion.value)
}
log.info(
s">> Change ThisBuild / scalafixScalaBinaryVersion from ${(ThisBuild / scalafixScalaBinaryVersion).value} to $newVersion"
)
newVersion
}
lazy val refined4s = (project in file("."))
.enablePlugins(DevOopsGitHubReleasePlugin)
.settings(mavenCentralPublishSettings)
.settings(noPublish)
.aggregate(
coreJvm,
coreJs,
catsJvm,
catsJs,
circeJvm,
circeJs,
pureconfigJvm,
pureconfigJs,
doobieCe2Jvm,
doobieCe2Js,
doobieCe3Jvm,
doobieCe3Js,
extrasRenderJvm,
extrasRenderJs,
refinedCompatScala2Jvm,
refinedCompatScala2Js,
refinedCompatScala3Jvm,
refinedCompatScala3Js,
tapirJvm,
tapirJs,
chimneyJvm,
chimneyJs,
)
lazy val core = module("core", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.extrasTypeInfo % Test,
libs.cats % Test,
)
)
lazy val coreJvm = core.jvm
lazy val coreJs = core.js.settings(jsSettingsForFuture)
lazy val cats = module("cats", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.cats,
libs.extrasTypeInfo % Test,
)
)
.dependsOn(core % props.IncludeTest)
lazy val catsJvm = cats.jvm
lazy val catsJs = cats.js.settings(jsSettingsForFuture)
lazy val circe = module("circe", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.circeCore,
libs.circeParser % Test,
libs.circeLiteral % Test,
libs.extrasTypeInfo % Test,
libs.extrasHedgehogCirce % Test,
)
)
.dependsOn(
core % props.IncludeTest,
cats,
)
lazy val circeJvm = circe.jvm
lazy val circeJs = circe.js.settings(jsSettingsForFuture)
lazy val pureconfig = module("pureconfig", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.pureconfigCore,
libs.extrasTypeInfo % Test,
)
)
.dependsOn(core % props.IncludeTest)
lazy val pureconfigJvm = pureconfig.jvm
lazy val pureconfigJs = pureconfig.js.settings(jsSettingsForFuture)
lazy val doobieCe2 = module("doobie-ce2", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.doobieCoreCe2,
libs.embeddedPostgres % Test,
libs.effectieCe2 % Test,
libs.extrasDoobieToolsCe2 % Test,
libs.logback % Test,
// libs.kittens % Test,
)
)
.dependsOn(
core % props.IncludeTest,
cats,
)
lazy val doobieCe2Jvm = doobieCe2.jvm
lazy val doobieCe2Js = doobieCe2.js.settings(jsSettingsForFuture)
lazy val doobieCe3 = module("doobie-ce3", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.doobieCoreCe3,
libs.embeddedPostgres % Test,
libs.effectieCe3 % Test,
libs.extrasDoobieToolsCe3 % Test,
libs.logback % Test,
// libs.kittens % Test,
)
)
.dependsOn(
core % props.IncludeTest,
cats,
)
lazy val doobieCe3Jvm = doobieCe3.jvm
lazy val doobieCe3Js = doobieCe3.js.settings(jsSettingsForFuture)
lazy val extrasRender = module("extras-render", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.extrasRender
)
)
.dependsOn(
core % props.IncludeTest
)
lazy val extrasRenderJvm = extrasRender.jvm
lazy val extrasRenderJs = extrasRender.js.settings(jsSettingsForFuture)
lazy val chimney = module("chimney", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.chimney,
libs.tests.hedgehogExtraRefined4s,
)
)
.dependsOn(
core % props.IncludeTest
)
lazy val chimneyJvm = chimney.jvm
lazy val chimneyJs = chimney.js.settings(jsSettingsForFuture)
lazy val refinedCompatScala2 = module("refined-compat-scala2", crossProject(JVMPlatform, JSPlatform))
.settings(
crossScalaVersions := List("2.12.15", "2.13.13"),
libraryDependencies ++=
(
if (isScala3(scalaVersion.value))
List.empty
else
List("eu.timepit" %% "refined" % "0.9.29")
),
)
lazy val refinedCompatScala2Jvm = refinedCompatScala2.jvm
lazy val refinedCompatScala2Js = refinedCompatScala2.js.settings(jsSettingsForFuture)
lazy val refinedCompatScala3 = module("refined-compat-scala3", crossProject(JVMPlatform, JSPlatform))
.dependsOn(
core % props.IncludeTest
)
lazy val refinedCompatScala3Jvm = refinedCompatScala3.jvm
lazy val refinedCompatScala3Js = refinedCompatScala3.js.settings(jsSettingsForFuture)
lazy val tapir = module("tapir", crossProject(JVMPlatform, JSPlatform))
.settings(
libraryDependencies ++= List(
libs.tapirCore
)
)
.dependsOn(
core % props.IncludeTest
)
lazy val tapirJvm = tapir.jvm
lazy val tapirJs = tapir.js.settings(jsSettingsForFuture)
lazy val docs = (project in file("docs-gen-tmp/docs"))
.enablePlugins(MdocPlugin, DocusaurPlugin)
.settings(
scalaVersion := props.Scala3Version,
name := prefixedProjectName("docs"),
scalacOptions ~= (ops => ops.filter(_ != "-Wunused:imports")),
mdocIn := file("docs"),
mdocOut := file("generated-docs/docs"),
cleanFiles += file("generated-docs/docs"),
libraryDependencies ++= {
import sys.process.*
"git fetch --tags".!
val tag = "git rev-list --tags --max-count=1".!!.trim
val latestVersion = s"git describe --tags $tag".!!.trim.stripPrefix("v")
List(
"io.kevinlee" %% "refined4s-core" % latestVersion,
"io.kevinlee" %% "refined4s-cats" % latestVersion,
"io.kevinlee" %% "refined4s-circe" % latestVersion,
"io.kevinlee" %% "refined4s-pureconfig" % latestVersion,
"io.kevinlee" %% "refined4s-doobie-ce2" % latestVersion,
"io.kevinlee" %% "refined4s-extras-render" % latestVersion,
"io.kevinlee" %% "refined4s-tapir" % latestVersion,
libs.circeCore,
libs.circeLiteral,
libs.circeParser,
)
},
mdocVariables := Map(
"VERSION" -> {
import sys.process.*
"git fetch --tags".!
val tag = "git rev-list --tags --max-count=1".!!.trim
s"git describe --tags $tag".!!.trim.stripPrefix("v")
}
),
docusaurDir := (ThisBuild / baseDirectory).value / "website",
docusaurBuildDir := docusaurDir.value / "build",
)
.settings(noPublish)
lazy val props =
new {
private val GitHubRepo = findRepoOrgAndName
val Org = "io.kevinlee"
val GitHubUsername = GitHubRepo.fold("kevin-lee")(_.orgToString)
val RepoName = GitHubRepo.fold("refined4s")(_.nameToString)
// val Scala3Version = "3.1.3"
val Scala3Version = "3.3.3"
val ProjectScalaVersion = Scala3Version
lazy val licenses = List("MIT" -> url("http://opensource.org/licenses/MIT"))
val SonatypeCredentialHost = "s01.oss.sonatype.org"
val SonatypeRepository = s"https://$SonatypeCredentialHost/service/local"
val SonatypeSnapshots = "sonatype-snapshots".at(s"https://$SonatypeCredentialHost/content/repositories/snapshots")
val removeDottyIncompatible: ModuleID => Boolean =
m =>
m.name == "ammonite" ||
m.name == "kind-projector" ||
m.name == "better-monadic-for" ||
m.name == "mdoc"
val IncludeTest = "compile->compile;test->test"
val HedgehogVersion = "0.10.1"
val HedgehogExtraVersion = "0.9.0"
val ExtrasVersion = "0.44.0"
val CatsVersion = "2.8.0"
val CirceVersion = "0.14.3"
val PureconfigVersion = "0.17.1"
val DoobieCe2Version = "0.13.4"
val DoobieCe3Version = "1.0.0-RC2"
val EmbeddedPostgresVersion = "2.0.7"
val EffectieVersion = "2.0.0-beta14"
val LogbackVersion = "1.5.6"
val KittensVersion = "3.0.0"
val TapirVersion = "1.0.6"
val ChimneyVersion = "1.3.0"
}
lazy val libs = new {
lazy val extrasTypeInfo = "io.kevinlee" %% "extras-type-info" % props.ExtrasVersion
lazy val extrasHedgehogCirce = "io.kevinlee" %% "extras-hedgehog-circe" % props.ExtrasVersion
lazy val extrasDoobieToolsCe2 = "io.kevinlee" %% "extras-doobie-tools-ce2" % props.ExtrasVersion
lazy val extrasDoobieToolsCe3 = "io.kevinlee" %% "extras-doobie-tools-ce3" % props.ExtrasVersion
lazy val extrasRender = "io.kevinlee" %% "extras-render" % props.ExtrasVersion
lazy val cats = "org.typelevel" %% "cats-core" % props.CatsVersion
lazy val kittens = "org.typelevel" %% "kittens" % props.KittensVersion
lazy val circeCore = "io.circe" %% "circe-core" % props.CirceVersion
lazy val circeParser = "io.circe" %% "circe-parser" % props.CirceVersion
lazy val circeLiteral = "io.circe" %% "circe-literal" % props.CirceVersion
lazy val pureconfigCore = "com.github.pureconfig" %% "pureconfig-core" % props.PureconfigVersion
lazy val pureconfigGeneric = "com.github.pureconfig" %% "pureconfig-generic" % props.PureconfigVersion
lazy val doobieCoreCe2 = "org.tpolecat" %% "doobie-core" % props.DoobieCe2Version
lazy val doobieCoreCe3 = "org.tpolecat" %% "doobie-core" % props.DoobieCe3Version
lazy val embeddedPostgres = "io.zonky.test" % "embedded-postgres" % props.EmbeddedPostgresVersion
lazy val effectieCore = "io.kevinlee" %% "effectie-core" % props.EffectieVersion
lazy val effectieSyntax = "io.kevinlee" %% "effectie-syntax" % props.EffectieVersion
lazy val effectieCe2 = "io.kevinlee" %% "effectie-cats-effect2" % props.EffectieVersion
lazy val effectieCe3 = "io.kevinlee" %% "effectie-cats-effect3" % props.EffectieVersion
lazy val logback = "ch.qos.logback" % "logback-classic" % props.LogbackVersion
lazy val hedgehogCore = "qa.hedgehog" %% "hedgehog-core" % props.HedgehogVersion
lazy val hedgehogRunner = "qa.hedgehog" %% "hedgehog-runner" % props.HedgehogVersion
lazy val hedgehogSbt = "qa.hedgehog" %% "hedgehog-sbt" % props.HedgehogVersion
lazy val tapirCore = "com.softwaremill.sttp.tapir" %% "tapir-core" % props.TapirVersion
lazy val chimney = "io.scalaland" %% "chimney" % props.ChimneyVersion
lazy val tests = new {
lazy val hedgehog: List[ModuleID] =
List(
hedgehogCore,
hedgehogRunner,
hedgehogSbt,
).map(_ % Test)
lazy val hedgehogExtraCore = "io.kevinlee" %% "hedgehog-extra-core" % props.HedgehogExtraVersion % Test
lazy val hedgehogExtraRefined4s = "io.kevinlee" %% "hedgehog-extra-refined4s" % props.HedgehogExtraVersion % Test
}
}
// scalafmt: off
def prefixedProjectName(name: String) = s"${props.RepoName}${if (name.isEmpty) "" else s"-$name"}"
// scalafmt: on
lazy val mavenCentralPublishSettings: SettingsDefinition = List(
/* Publish to Maven Central { */
sonatypeCredentialHost := props.SonatypeCredentialHost,
sonatypeRepository := props.SonatypeRepository,
/* } Publish to Maven Central */
)
def isScala3(scalaVersion: String): Boolean = scalaVersion.startsWith("3")
def module(projectName: String, crossProject: CrossProject.Builder): CrossProject = {
val prefixedName = prefixedProjectName(projectName)
crossProject
.in(file(s"modules/$prefixedName"))
.settings(
name := prefixedName,
fork := true,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
else
((ThisBuild / baseDirectory).value / ".scalafix-scala2.conf").some
),
scalacOptions ++= (if (isScala3(scalaVersion.value)) List("-no-indent") else List("-Xsource:3")),
// scalacOptions ~= (ops => ops.filter(_ != "UTF-8")),
libraryDependencies ++= libs.tests.hedgehog ++ List(libs.tests.hedgehogExtraCore),
wartremoverErrors ++= Warts.allBut(Wart.Any, Wart.Nothing, Wart.ImplicitConversion, Wart.ImplicitParameter),
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
Test / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
/* } WartRemover and scalacOptions */
licenses := props.licenses,
/* coverage { */
coverageHighlighting := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) | Some((2, 11)) =>
false
case _ =>
true
}),
/* } coverage */
// scalacOptions ~= (_.filterNot(_.startsWith("-language"))),
// scalacOptions ++= List(
// "-language:dynamics",
// "-language:existentials",
// "-language:higherKinds",
// "-language:reflectiveCalls",
// "-language:experimental.macros",
// "-language:implicitConversions",
// ),
)
.settings(mavenCentralPublishSettings)
}
lazy val jsSettingsForFuture: SettingsDefinition = List(
Test / fork := false,
Test / scalacOptions ++= (if (scalaVersion.value.startsWith("3")) List.empty
else List("-P:scalajs:nowarnGlobalExecutionContext")),
Test / compile / scalacOptions ++= (if (scalaVersion.value.startsWith("3")) List.empty
else List("-P:scalajs:nowarnGlobalExecutionContext")),
)