-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
build.sbt
575 lines (542 loc) · 23.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
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
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import com.typesafe.tools.mima.core.{Problem, ProblemFilters}
import commandmatrix.extra.*
import sbtprotoc.ProtocPlugin.ProtobufConfig
// Used to configure the build so that it would format on compile during development but not on CI.
lazy val isCI = sys.env.get("CI").contains("true")
ThisBuild / scalafmtOnCompile := !isCI
lazy val ciRelease = taskKey[Unit](
"Publish artifacts to release or snapshot (skipping sonatypeBundleRelease which is unnecessary for snapshots)"
)
ciRelease := {
publishSigned.taskValue
Def.taskIf {
if (git.gitCurrentTags.value.nonEmpty) {
sonatypeBundleRelease.taskValue
}
}
}
// Versions:
val versions = new {
val scala212 = "2.12.20"
val scala213 = "2.13.15"
val scala3 = "3.3.4"
// Which versions should be cross-compiled for publishing
val scalas = List(scala212, scala213, scala3)
val platforms = List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native)
// Which version should be used in IntelliJ
val ideScala = scala3
val idePlatform = VirtualAxis.jvm
// Dependencies
val cats = "2.12.0"
val kindProjector = "0.13.3"
val munit = "1.0.2"
val scalaCollectionCompat = "2.12.0"
val scalaJavaCompat = "1.0.2"
val scalaJavaTime = "2.6.0"
val scalapbRuntime = scalapb.compiler.Version.scalapbVersion
}
// Common settings:
Global / excludeLintKeys += git.useGitDescribe
Global / excludeLintKeys += ideSkipProject
val only1VersionInIDE =
MatrixAction
.ForPlatform(versions.idePlatform)
.Configure(
_.settings(
ideSkipProject := (scalaVersion.value != versions.ideScala),
bspEnabled := (scalaVersion.value == versions.ideScala),
scalafmtOnCompile := !isCI
)
) +:
versions.platforms.filter(_ != versions.idePlatform).map { platform =>
MatrixAction
.ForPlatform(platform)
.Configure(_.settings(ideSkipProject := true, bspEnabled := false, scalafmtOnCompile := false))
}
val addScala213plusDir =
MatrixAction
.ForScala(v => (v.value == versions.scala213) || v.isScala3)
.Configure(
_.settings(
Compile / unmanagedSourceDirectories += sourceDirectory.value.toPath.resolve("main/scala-2.13+").toFile,
Test / unmanagedSourceDirectories += sourceDirectory.value.toPath.resolve("test/scala-2.13+").toFile
)
)
val settings = Seq(
git.useGitDescribe := true,
git.uncommittedSignifier := None,
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq(
// format: off
"-encoding", "UTF-8",
"-rewrite",
"-source", "3.3-migration",
// format: on
"-unchecked",
"-deprecation",
"-explain",
"-explain-types",
"-feature",
"-no-indent",
"-Wconf:msg=Unreachable case:s", // suppress fake (?) errors in internal.compiletime
"-Wconf:msg=Missing symbol position:s", // suppress warning https://github.com/scala/scala3/issues/21672
"-Wnonunit-statement",
// "-Wunused:imports", // import x.Underlying as X is marked as unused even though it is! probably one of https://github.com/scala/scala3/issues/: #18564, #19252, #19657, #19912
"-Wunused:privates",
"-Wunused:locals",
"-Wunused:explicits",
"-Wunused:implicits",
"-Wunused:params",
"-Wvalue-discard",
"-Xfatal-warnings",
"-Xcheck-macros",
"-Ykind-projector:underscores"
)
case Some((2, 13)) =>
Seq(
// format: off
"-encoding", "UTF-8",
"-release", "8",
// format: on
"-unchecked",
"-deprecation",
"-explaintypes",
"-feature",
"-language:higherKinds",
"-Wconf:origin=scala.collection.compat.*:s", // type aliases without which 2.12 fail compilation but 2.13/3 doesn't need them
"-Wconf:cat=scala3-migration:s", // silence mainly issues with -Xsource:3 and private case class constructors
"-Wconf:cat=deprecation&origin=io.scalaland.chimney.*:s", // we want to be able to deprecate APIs and test them while they're deprecated
"-Wconf:msg=The outer reference in this type test cannot be checked at run time:s", // suppress fake(?) errors in internal.compiletime (adding origin breaks this suppression)
"-Wconf:src=io/scalaland/chimney/cats/package.scala:s", // silence package object inheritance deprecation
"-Wconf:msg=discarding unmoored doc comment:s", // silence errors when scaladoc cannot comprehend nested vals
"-Wconf:msg=Could not find any member to link for:s", // since errors when scaladoc cannot link to stdlib types or nested types
"-Wconf:msg=Variable .+ undefined in comment for:s", // silence errors when there we're showing a buggy Expr in scaladoc comment
"-Wunused:patvars",
"-Xfatal-warnings",
"-Xlint:adapted-args",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:nullary-unit",
"-Xlint:option-implicit",
"-Xlint:package-object-classes",
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xsource:3",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-unused:locals",
"-Ywarn-unused:imports",
"-Ywarn-macros:after",
"-Ytasty-reader"
)
case Some((2, 12)) =>
Seq(
// format: off
"-encoding", "UTF-8",
"-target:jvm-1.8",
// format: on
"-unchecked",
"-deprecation",
"-explaintypes",
"-feature",
"-language:higherKinds",
"-Wconf:cat=deprecation&origin=io.scalaland.chimney.*:s", // we want to be able to deprecate APIs and test them while they're deprecated
"-Wconf:msg=The outer reference in this type test cannot be checked at run time:s", // suppress fake(?) errors in internal.compiletime (adding origin breaks this suppression)
"-Wconf:src=io/scalaland/chimney/cats/package.scala:s", // silence package object inheritance deprecation
"-Wconf:msg=discarding unmoored doc comment:s", // silence errors when scaladoc cannot comprehend nested vals
"-Wconf:msg=Could not find any member to link for:s", // since errors when scaladoc cannot link to stdlib types or nested types
"-Wconf:msg=Variable .+ undefined in comment for:s", // silence errors when there we're showing a buggy Expr in scaladoc comment
"-Xexperimental",
"-Xfatal-warnings",
"-Xfuture",
"-Xlint:adapted-args",
"-Xlint:by-name-right-associative",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:nullary-override",
"-Xlint:nullary-unit",
"-Xlint:option-implicit",
"-Xlint:package-object-classes",
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:unsound-match",
"-Xsource:3",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-numeric-widen",
"-Ywarn-unused:locals",
"-Ywarn-unused:imports",
"-Ywarn-macros:after",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit"
)
case _ => Seq.empty
}
},
Compile / doc / scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq("-Ygenerate-inkuire") // type-based search for Scala 3, this option cannot go into compile
case _ => Seq.empty
}
},
Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"),
Test / compile / scalacOptions --= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq("-Ywarn-unused:locals") // Scala 2.12 ignores @unused warns
case _ => Seq.empty
}
},
coverageExcludedPackages := ".*DefCache.*" // DefCache is kind-a experimental utility
)
val dependencies = Seq(
libraryDependencies ++= Seq(
"org.scala-lang.modules" %%% "scala-collection-compat" % versions.scalaCollectionCompat,
"org.scalameta" %%% "munit" % versions.munit % Test
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
compilerPlugin("org.typelevel" % "kind-projector" % versions.kindProjector cross CrossVersion.full)
)
case _ => Seq.empty
}
}
)
val versionSchemeSettings = Seq(versionScheme := Some("early-semver"))
val publishSettings = Seq(
organization := "io.scalaland",
homepage := Some(url("https://scalaland.io/chimney")),
organizationHomepage := Some(url("https://scalaland.io")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(
ScmInfo(url("https://github.com/scalalandio/chimney/"), "scm:git:[email protected]:scalalandio/chimney.git")
),
startYear := Some(2017),
developers := List(
Developer("krzemin", "Piotr Krzemiński", "", url("https://github.com/krzemin")),
Developer("MateuszKubuszok", "Mateusz Kubuszok", "", url("https://github.com/MateuszKubuszok"))
),
pomExtra := (
<issueManagement>
<system>GitHub issues</system>
<url>https://github.com/scalalandio/chimney/issues</url>
</issueManagement>
),
publishTo := sonatypePublishToBundle.value,
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ =>
false
},
// Sonatype ignores isSnapshot setting and only looks at -SNAPSHOT suffix in version:
// https://central.sonatype.org/publish/publish-maven/#performing-a-snapshot-deployment
// meanwhile sbt-git used to set up SNAPSHOT if there were uncommitted changes:
// https://github.com/sbt/sbt-git/issues/164
// (now this suffix is empty by default) so we need to fix it manually.
git.gitUncommittedChanges := git.gitCurrentTags.value.isEmpty,
git.uncommittedSignifier := Some("SNAPSHOT")
)
val mimaSettings = Seq(
mimaPreviousArtifacts := {
val previousVersions = moduleName.value match {
case "chimney-macro-commons" => Set("1.0.0-RC1", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0")
case "chimney" => Set("1.0.0-RC1", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0")
case "chimney-cats" => Set("1.0.0-RC1", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0")
case "chimney-java-collections" => Set("1.0.0-RC1", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0")
case "chimney-protobufs" => Set("1.0.0-RC1", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0")
case _ => Set()
}
previousVersions.map(organization.value %% moduleName.value % _)
},
mimaFailOnNoPrevious := true
)
val noPublishSettings =
Seq(publish / skip := true, publishArtifact := false)
val ciCommand = (platform: String, scalaSuffix: String) => {
val isJVM = platform == "JVM"
val clean = Vector("clean")
def withCoverage(tasks: String*): Vector[String] =
"coverage" +: tasks.toVector :+ "coverageAggregate" :+ "coverageOff"
val projects = for {
name <- Vector(
"chimney",
"chimneyCats",
"chimneyProtobufs",
if (isJVM) "chimneyJavaCollections" else "",
"chimneyEngine"
)
if name.nonEmpty
} yield s"$name${if (isJVM) "" else platform}$scalaSuffix"
def tasksOf(name: String): Vector[String] = projects.map(project => s"$project/$name")
val tasks = if (isJVM) {
clean ++
withCoverage((tasksOf("compile") ++ tasksOf("test") ++ tasksOf("coverageReport")).toSeq *) ++
Vector("benchmarks/compile") ++
tasksOf("mimaReportBinaryIssues")
} else {
clean ++ tasksOf("test")
}
tasks.mkString(" ; ")
}
val publishLocalForTests = {
val jvm = for {
module <- Vector("chimneyMacroCommons", "chimney", "chimneyCats", "chimneyProtobufs", "chimneyJavaCollections")
moduleVersion <- Vector(module, module + "3")
} yield moduleVersion + "/publishLocal"
val js = for {
module <- Vector("chimneyMacroCommons", "chimney").map(_ + "JS")
moduleVersion <- Vector(module)
} yield moduleVersion + "/publishLocal"
jvm ++ js
}.mkString(" ; ")
val releaseCommand = (tag: Seq[String]) =>
if (tag.nonEmpty) "publishSigned ; sonatypeBundleRelease" else "publishSigned"
// modules
lazy val root = project
.in(file("."))
.enablePlugins(GitVersioning, GitBranchPrompt)
.settings(settings)
.settings(publishSettings)
.settings(noPublishSettings)
.aggregate(chimneyMacroCommons.projectRefs *)
.aggregate(chimney.projectRefs *)
.aggregate(chimneyCats.projectRefs *)
.aggregate(chimneyJavaCollections.projectRefs *)
.aggregate(chimneyProtobufs.projectRefs *)
.aggregate(chimneyEngine.projectRefs *)
.settings(
moduleName := "chimney-build",
name := "chimney-build",
description := "Build setup for Chimney modules",
logo :=
s"""Chimney ${(version).value} build for (${versions.scala212}, ${versions.scala213}, ${versions.scala3}) x (Scala JVM, Scala.js $scalaJSVersion, Scala Native $nativeVersion)
|
|This build uses sbt-projectmatrix with sbt-commandmatrix helper:
| - Scala JVM adds no suffix to a project name seen in build.sbt
| - Scala.js adds the "JS" suffix to a project name seen in build.sbt
| - Scala Native adds the "Native" suffix to a project name seen in build.sbt
| - Scala 2.12 adds the suffix "2_12" to a project name seen in build.sbt
| - Scala 2.13 adds no suffix to a project name seen in build.sbt
| - Scala 3 adds the suffix "3" to a project name seen in build.sbt
|
|When working with IntelliJ or Scala Metals, edit "val ideScala = ..." and "val idePlatform = ..." within "val versions" in build.sbt to control which Scala version you're currently working with.
|
|If you need to test library locally in a different project, use publish-local-for-tests or manually publishLocal:
| - chimney-macro-commons (obligatory)
| - chimney
| - cats/java-collections/protobufs integration (optional)
|for the right Scala version and platform (see projects task).
|""".stripMargin,
usefulTasks := Seq(
sbtwelcome.UsefulTask("projects", "List all projects generated by the build matrix").noAlias,
sbtwelcome
.UsefulTask(
"test",
"Compile and test all projects in all Scala versions and platforms (beware! it uses a lot of memory and might OOM!)"
)
.noAlias,
sbtwelcome.UsefulTask("chimney3/console", "Drop into REPL with Chimney DSL imported (3)").noAlias,
sbtwelcome.UsefulTask("chimney/console", "Drop into REPL with Chimney DSL imported (2.13)").noAlias,
sbtwelcome
.UsefulTask(releaseCommand(git.gitCurrentTags.value), "Publish everything to release or snapshot repository")
.alias("ci-release"),
sbtwelcome.UsefulTask("benchmarks/Jmh/run", "Run JMH benchmarks suite").alias("runBenchmarks"),
sbtwelcome.UsefulTask(ciCommand("JVM", "3"), "CI pipeline for Scala 3 on JVM").alias("ci-jvm-3"),
sbtwelcome.UsefulTask(ciCommand("JVM", ""), "CI pipeline for Scala 2.13 on JVM").alias("ci-jvm-2_13"),
sbtwelcome.UsefulTask(ciCommand("JVM", "2_12"), "CI pipeline for Scala 2.12 on JVM").alias("ci-jvm-2_12"),
sbtwelcome.UsefulTask(ciCommand("JS", "3"), "CI pipeline for Scala 3 on Scala JS").alias("ci-js-3"),
sbtwelcome.UsefulTask(ciCommand("JS", ""), "CI pipeline for Scala 2.13 on Scala JS").alias("ci-js-2_13"),
sbtwelcome.UsefulTask(ciCommand("JS", "2_12"), "CI pipeline for Scala 2.12 on Scala JS").alias("ci-js-2_12"),
sbtwelcome.UsefulTask(ciCommand("Native", "3"), "CI pipeline for Scala 3 on Scala Native").alias("ci-native-3"),
sbtwelcome
.UsefulTask(ciCommand("Native", ""), "CI pipeline for Scala 2.13 on Scala Native")
.alias("ci-native-2_13"),
sbtwelcome
.UsefulTask(ciCommand("Native", "2_12"), "CI pipeline for Scala 2.12 on Scala Native")
.alias("ci-native-2_12"),
sbtwelcome
.UsefulTask(
publishLocalForTests,
"Publishes all Scala 2.13 and Scala 3 JVM artifacts to test snippets in documentation"
)
.alias("publish-local-for-tests")
)
)
lazy val chimneyMacroCommons = projectMatrix
.in(file("chimney-macro-commons"))
.someVariations(versions.scalas, versions.platforms)((addScala213plusDir +: only1VersionInIDE) *)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin, ProtocPlugin)
.settings(
moduleName := "chimney-macro-commons",
name := "chimney-macro-commons",
description := "Utilities for writing cross-platform macro logic"
)
.settings(settings *)
.settings(versionSchemeSettings *)
.settings(publishSettings *)
.settings(dependencies *)
lazy val chimney = projectMatrix
.in(file("chimney"))
.someVariations(versions.scalas, versions.platforms)((addScala213plusDir +: only1VersionInIDE) *)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin, ProtocPlugin)
.settings(
moduleName := "chimney",
name := "chimney",
description := "Scala library for boilerplate-free data rewriting"
)
.settings(settings *)
.settings(versionSchemeSettings *)
.settings(publishSettings *)
.settings(mimaSettings *)
.settings(dependencies *)
.settings(
Compile / console / initialCommands := "import io.scalaland.chimney.*, io.scalaland.chimney.dsl.*",
Compile / doc / scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq("-skip-by-regex:io\\.scalaland\\.chimney\\.internal")
case Some((2, _)) => Seq("-skip-packages", "io.scalaland.chimney.internal")
case _ => Seq.empty
}
},
// Changes to macros should not cause any runtime problems
mimaBinaryIssueFilters := Seq(ProblemFilters.exclude[Problem]("io.scalaland.chimney.internal.compiletime.*"))
)
.dependsOn(chimneyMacroCommons)
lazy val chimneyCats = projectMatrix
.in(file("chimney-cats"))
.someVariations(versions.scalas, versions.platforms)((addScala213plusDir +: only1VersionInIDE) *)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin, ProtocPlugin)
.settings(
moduleName := "chimney-cats",
name := "chimney-cats",
description := "Integrations with selected Cats data types and type classes"
)
.settings(settings *)
.settings(versionSchemeSettings *)
.settings(publishSettings *)
.settings(mimaSettings *)
.settings(dependencies *)
.settings(
Compile / console / initialCommands := "import io.scalaland.chimney.*, io.scalaland.chimney.dsl.*, io.scalaland.chimney.cats.*",
libraryDependencies += "org.typelevel" %%% "cats-core" % versions.cats,
libraryDependencies += "org.typelevel" %%% "cats-laws" % versions.cats % Test
)
.dependsOn(chimney % s"$Test->$Test;$Compile->$Compile")
lazy val chimneyJavaCollections = projectMatrix
.in(file("chimney-java-collections"))
.someVariations(versions.scalas, List(VirtualAxis.jvm))(only1VersionInIDE *)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin)
.settings(
moduleName := "chimney-java-collections",
name := "chimney-java-collections",
description := "Integrations with selected Java collections"
)
.settings(settings *)
.settings(versionSchemeSettings *)
.settings(publishSettings *)
.settings(mimaSettings *)
.settings(
Compile / console / initialCommands := "import io.scalaland.chimney.*, io.scalaland.chimney.dsl.*, io.scalaland.chimney.javacollections.*",
// Scala 2.12 doesn't have scala.jdk.StreamConverters and we use it in test of java.util.stream type class instances
libraryDependencies += "org.scala-lang.modules" %%% "scala-java8-compat" % versions.scalaJavaCompat % Test
)
.dependsOn(chimney % s"$Test->$Test;$Compile->$Compile")
lazy val chimneyProtobufs = projectMatrix
.in(file("chimney-protobufs"))
.someVariations(versions.scalas, versions.platforms)(
(only1VersionInIDE :+ MatrixAction
.ForPlatforms(VirtualAxis.js, VirtualAxis.native)
.Settings(
// Scala.js and Scala Native decided to not implement java.time and let an external library do it,
// meanwhile we want to provide some type class instances for types in java.time.
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % versions.scalaJavaTime
)) *
)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin)
.settings(
moduleName := "chimney-protobufs",
name := "chimney-protobufs",
description := "Integrations with selected Protobufs build-in types"
)
.settings(settings *)
.settings(versionSchemeSettings *)
.settings(publishSettings *)
.settings(mimaSettings *)
.settings(
Compile / console / initialCommands := "import io.scalaland.chimney.*, io.scalaland.chimney.dsl.*, io.scalaland.chimney.protobufs.*",
scalacOptions := {
// protobufs Compile contains only generated classes, and scalacOptions from settings:* breaks Scala 3 compilation
val resetOptions = if (scalacOptions.value.contains("-scalajs")) Seq("-scalajs") else Seq.empty
val reAddNecessary = CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) =>
Seq(
"-language:higherKinds"
)
case _ => Seq.empty
}
resetOptions ++ reAddNecessary
},
Compile / PB.targets := Seq(scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"),
Test / PB.protoSources += PB.externalSourcePath.value,
Test / PB.targets := Seq(scalapb.gen() -> (Test / sourceManaged).value / "scalapb"),
libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime" % versions.scalapbRuntime % ProtobufConfig
)
.dependsOn(chimney % s"$Test->$Test;$Compile->$Compile")
lazy val chimneyEngine = projectMatrix
.in(file("chimney-engine"))
.someVariations(versions.scalas, versions.platforms)((addScala213plusDir +: only1VersionInIDE) *)
.enablePlugins(GitVersioning, GitBranchPrompt)
.disablePlugins(WelcomePlugin, ProtocPlugin)
.settings(
moduleName := "chimney-engine",
name := "chimney-engine",
description := "Chimney derivation engine exposed for reuse in other libraries"
)
.settings(settings *)
.settings(versionScheme := None) // macros internal API is NOT stable yet
.settings(publishSettings *)
// .settings(mimaSettings *) // we need to get some feedback before we stabilize this
.settings(
coverageExcludedPackages := "io.scalaland.chimney.internal.compiletime.*", // we're only checking if it compiles
mimaFailOnNoPrevious := false // this hasn't been published yet
)
.settings(dependencies *)
.dependsOn(chimney)
lazy val benchmarks = projectMatrix
.in(file("benchmarks"))
.someVariations(List(versions.scala213), List(VirtualAxis.jvm))(only1VersionInIDE *) // only makes sense for JVM
.settings(
moduleName := "chimney-benchmarks",
name := "chimney-benchmarks",
description := "Chimney benchmarking harness"
)
.enablePlugins(JmhPlugin)
.disablePlugins(WelcomePlugin, ProtocPlugin)
.settings(settings *)
.settings(noPublishSettings *)
.dependsOn(chimney)
//when having memory/GC-related errors during build, uncommenting this may be useful:
Global / concurrentRestrictions := Seq(
Tags.limit(Tags.Compile, 2) // only 2 compilations at once
)