Skip to content

Commit 83bf4dc

Browse files
Migrate build to sbt 2.0.2
Moves the build from sbt 1.12.13 to sbt 2.0.2. sbt 2.x compiles the build definition with Scala 3 (not 2.12), runs on JDK 17+, in-sources projectMatrix, caches settings/tasks, and hardens several policies - each needed adjustments. Plugins (project/plugins.sbt): - All plugins now resolve their sbt-2 (`_sbt2_3`) builds; addSbtPlugin syntax is unchanged. - sbt-projectmatrix: dropped - projectMatrix/VirtualAxis/MatrixAction are in sbt 2 core (the standalone plugin has no sbt-2 build and is archived). - sbt-ide-settings: org.jetbrains % 1.1.0 -> org.jetbrains.scala % 1.1.4 (only the new coordinate publishes for sbt 2). - sbt-protoc: 1.0.8 -> 1.1.0-RC2 (only sbt-2 build; no stable release yet) and the scalapb compilerplugin 0.11.20 -> 1.0.0-alpha.6. Required: sbt-protoc RC2 pulls protoc-bridge_3, which on the scalapb side only lines up with the 1.0.0-alpha line; stable scalapb (0.11.20) still resolves protoc-gen_2.13/protoc-bridge_2.13 and fails sbt's cross-version-suffix check. This bumps the chimney-protobufs runtime (scalapbRuntime derives from compilerplugin) onto scalapb 1.0.0-alpha.6. build.sbt DSL: - `versions`/`dev` moved from build.sbt-local `val ... = new { ... }` into objects in project/BuildVersions.scala. Scala 3 widens an anonymous object to `Object` and hides its members, and sbt does not lift build.sbt-local objects into the settings scope; as project/*.scala objects they stay referenceable unqualified. - `%%%` -> `%%` (sbt 2.x `%%` is platform-aware for projectMatrix JS/Native cells; `%%%` no longer exists). - Task caching: `scalacOptions --=` on a both-empty `fold` inferred Seq[Nothing] (no JsonFormat); typed the empties as Seq.empty[String]. - `x cross y` infix -> `x.cross(y)` (Scala 3 infix rule). - CI command builders (ciCommand / publishLocalForTests), console tasks and logo updated for sbt 2.x's flipped projectMatrix cell-id suffixes: Scala 3 is now unsuffixed and Scala 2.13 is "2_13" (was: 2.13 unsuffixed, Scala 3 "3"). - allowMismatchScala := true on chimneySandwichTests: sbt 2.x rejects a cross-Scala projectDependency by default, but that 2.13x3 dependency is the point of the sandwich tests. - evictionErrorLevel := Level.Warn: sbt 2.x promotes eviction conflicts to hard errors; on Scala Native, cats-laws (Test) -> scalacheck pulls scala-native test-interface 0.5.8 vs chimney's 0.5.12 (a benign 0.5.x upgrade). Restore warn. .jvmopts: -Xmx2g -> -Xmx6g. Scala 3 Scala-Native codegen (in-process LLVM IR for the whole macro-generated codebase) OOMs at 2g under sbt 2.x; 4g already clears it with no GC pressure, 6g leaves headroom (fine on 16GB CI runners). Workflows (.github/workflows/ci.yml): - Scala 2.13 build jobs moved from temurin:11 to temurin:17 - sbt 2.x requires JDK 17+ to run, so the old 2.13-on-JDK-11 job is no longer possible. Emitted bytecode stays JDK 11/17 compatible via the -release flags. (release.yml and the snippets job already run on 17; benchmark.yml on 21.) Validated on sbt 2.0.2 (JDK 24): the full test matrix is green - Scala 2.13 and Scala 3, each on JVM / Scala.js / Scala Native (Native Scala 3 needs the 6g heap). Hearth resolves to 0.4.1; hearth_sjs1/hearth_native0.5 resolve via the platform- aware %%. Not re-verified: MiMa (dormant pre-2.0.0) and the coverage/doc tasks.
1 parent c9b08b4 commit 83bf4dc

6 files changed

Lines changed: 137 additions & 107 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,11 @@ jobs:
6464
matrix:
6565
scala: ["2_13", "3"]
6666
platform: ["jvm", "js", "native"]
67-
# Chimney 2.x JDK baselines: Scala 2.13 targets JDK 11+ (-release 11), Scala 3 targets JDK 17+ (-release 17) -
68-
# each Scala version is tested on its minimum plus the latest LTS.
69-
jvm: ['temurin:11', 'temurin:1.21.0.1']
70-
exclude:
71-
- scala: "3"
72-
jvm: 'temurin:11'
73-
include:
74-
- { scala: "3", platform: "jvm", jvm: 'temurin:17' }
75-
- { scala: "3", platform: "js", jvm: 'temurin:17' }
76-
- { scala: "3", platform: "native", jvm: 'temurin:17' }
67+
# sbt 2.x requires JDK 17+ to run, so JDK 17 is the floor for every job (the old Scala 2.13-on-JDK-11
68+
# job is no longer possible - sbt itself won't start on 11). Emitted artifacts stay JDK-11 compatible
69+
# for Scala 2.13 (-release 11) and JDK-17 for Scala 3 (-release 17) via the -release flags; each Scala
70+
# version is also exercised on the latest LTS.
71+
jvm: ['temurin:17', 'temurin:1.21.0.1']
7772
fail-fast: false
7873

7974
steps:

.jvmopts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-XX:-OmitStackTraceInFastThrow
22
-XX:+UseG1GC
3-
-Xmx2g
3+
-Xmx6g

build.sbt

Lines changed: 51 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,24 @@ import scoverage.ScoverageKeys.coverageScalacPluginVersion
88
lazy val isCI = sys.env.get("CI").contains("true")
99
ThisBuild / scalafmtOnCompile := !isCI
1010

11+
// sbt 2.x promotes dependency eviction conflicts to hard errors by default (sbt 1.x defaulted to a warning). One such
12+
// conflict is benign here: on Scala Native, cats-laws (Test) pulls scalacheck -> scala-native test-interface 0.5.8,
13+
// while chimney uses 0.5.12 - a compatible 0.5.x upgrade sbt resolves to 0.5.12. Restore the sbt 1.x warn level.
14+
ThisBuild / evictionErrorLevel := Level.Warn
15+
1116
// Used to publish snapshots to Maven Central.
1217
val mavenCentralSnapshots = "Maven Central Snapshots" at "https://central.sonatype.com/repository/maven-snapshots"
1318

1419
// TODO: remove this once we have a release of Scala 2.13.17
1520
Global / resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
1621

1722
// Versions:
18-
19-
val versions = new {
20-
// Versions we are publishing for.
21-
val scala213 = "2.13.18"
22-
val scala3 = "3.8.4"
23-
// For chimney-sandwich-test-cases-3 ONLY: sbt forbids Scala 2.13 subprojects from depending on Scala 3.8+
24-
// subprojects (sbt-8728), and 2.13's -Ytasty-reader tops out below TASTy 28.8 - see the module for details.
25-
val scala3Sandwich = "3.7.3"
26-
27-
// Which versions should be cross-compiled for publishing
28-
val scalas = List(scala213, scala3)
29-
30-
val platforms = List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native)
31-
32-
// Dependencies.
33-
val hearth = "0.4.1"
34-
val cats = "2.13.0"
35-
// kindlings 0.3.1 is the first release on hearth 0.4.1 and includes kubuszok/kindlings#163
36-
// (NonEmptySeq/NonEmptyLazyList IsCollection providers).
37-
val kindlingsCatsIntegration = "0.3.1"
38-
val kindProjector = "0.13.4"
39-
val munit = "1.3.4"
40-
val scalaCollectionCompat = "2.14.0"
41-
val scalaJavaCompat = "1.0.2"
42-
val scalaJavaTime = "2.7.0"
43-
val scalapbRuntime = scalapb.compiler.Version.scalapbVersion
44-
45-
// Explicitly handle Scala 2.13 and Scala 3 separately.
46-
def fold[A](scalaVersion: String)(for2_13: => Seq[A], for3: => Seq[A]): Seq[A] =
47-
CrossVersion.partialVersion(scalaVersion) match {
48-
case Some((2, 13)) => for2_13
49-
case Some((3, _)) => for3
50-
case _ => Seq.empty // for sbt
51-
}
52-
}
53-
54-
// Development settings:
55-
56-
val dev = new {
57-
58-
val props = scala.util
59-
.Using(new java.io.FileInputStream("dev.properties")) { fis =>
60-
val props = new java.util.Properties()
61-
props.load(fis)
62-
props
63-
}
64-
.get
65-
66-
// Which version should be used in IntelliJ
67-
val ideScala = props.getProperty("ide.scala") match {
68-
case "2.13" => versions.scala213
69-
case "3" => versions.scala3
70-
}
71-
val idePlatform = props.getProperty("ide.platform") match {
72-
case "jvm" => VirtualAxis.jvm
73-
case "js" => VirtualAxis.js
74-
case "native" => VirtualAxis.native
75-
}
76-
77-
def isIdeScala(scalaVersion: String): Boolean =
78-
CrossVersion.partialVersion(scalaVersion) == CrossVersion.partialVersion(ideScala)
79-
def isIdePlatform(platform: VirtualAxis): Boolean = platform == idePlatform
80-
}
23+
//
24+
// `versions` (publish/dependency versions + the `fold` helper) and `dev` (IDE dev settings) are defined as objects in
25+
// project/BuildVersions.scala. Under sbt 1.x they were `val ... = new { ... }` in build.sbt, but sbt 2.x compiles
26+
// build.sbt with Scala 3, which hides an anonymous object's members and does not bring build.sbt-local objects into
27+
// the settings scope - so they were moved to project/*.scala, where they are real objects on the meta-build classpath
28+
// and remain referenceable here unqualified (`versions.scala3`, `dev.idePlatform`, ...).
8129

8230
// Common settings:
8331

@@ -192,22 +140,25 @@ val settings = Seq(
192140
for2_13 = Seq.empty
193141
),
194142
Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings", "-Werror"),
143+
// NOTE: the empties are typed `Seq.empty[String]`. sbt 2.x caches setting values and needs a JsonFormat for the
144+
// value type; untyped `Seq.empty` infers `Seq[Nothing]`, for which no JsonFormat exists (the fold's other call sites
145+
// infer `Seq[String]` from their non-empty branch, so only this both-empty call needs the annotation).
195146
Test / compile / scalacOptions --= versions.fold(scalaVersion.value)(
196-
for3 = Seq.empty,
197-
for2_13 = Seq.empty
147+
for3 = Seq.empty[String],
148+
for2_13 = Seq.empty[String]
198149
),
199150
coverageExcludedPackages := ".*DefCache.*" // DefCache is kind-a experimental utility
200151
)
201152

202153
val dependencies = Seq(
203154
libraryDependencies ++= Seq(
204-
"org.scalameta" %%% "munit" % versions.munit % Test
155+
"org.scalameta" %% "munit" % versions.munit % Test
205156
),
206157
libraryDependencies ++= versions.fold(scalaVersion.value)(
207158
for3 = Seq.empty,
208159
for2_13 = Seq(
209160
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
210-
compilerPlugin("org.typelevel" % "kind-projector" % versions.kindProjector cross CrossVersion.full)
161+
compilerPlugin(("org.typelevel" % "kind-projector" % versions.kindProjector).cross(CrossVersion.full))
211162
)
212163
)
213164
)
@@ -266,9 +217,17 @@ val mimaSettings = Seq(
266217
val noPublishSettings =
267218
Seq(publish / skip := true, publishArtifact := false)
268219

220+
// NOTE: sbt 2.x's in-core projectMatrix flipped the cell-id suffix scheme vs sbt 1.x (sbt-projectmatrix). Under
221+
// sbt 1.x the Scala 2.13 cell was unsuffixed and Scala 3 was "3" (`chimney`, `chimney3`); under sbt 2.x the Scala 3
222+
// cell is unsuffixed and Scala 2.13 is "2_13" (`chimney`, `chimney2_13`). Platform still lives in the name (JS/Native).
223+
// These generated flat ids are the valid command-line references; the axis form `name@scalaBinaryVersion=3` also works
224+
// for Scala 3 but not for 2.13 (the `.` in the value breaks the parser), so we stick to flat ids everywhere.
269225
val ciCommand = (platform: String, scalaSuffix: String) => {
270226
val isJVM = platform == "JVM"
271227
val isSandwichable = isJVM
228+
// The `scalaSuffix` argument still uses the old sbt 1.x convention ("" = 2.13, "3" = Scala 3); translate it to the
229+
// sbt 2.x cell suffix ("" = Scala 3, "2_13" = Scala 2.13).
230+
val cellScalaSuffix = if (scalaSuffix == "3") "" else "2_13"
272231

273232
val clean = Vector("clean")
274233
def withCoverage(tasks: String*): Vector[String] =
@@ -283,13 +242,13 @@ val ciCommand = (platform: String, scalaSuffix: String) => {
283242
if (isSandwichable) "chimneySandwichTests" else ""
284243
)
285244
if name.nonEmpty
286-
} yield s"$name${if (isJVM) "" else platform}$scalaSuffix"
245+
} yield s"$name${if (isJVM) "" else platform}$cellScalaSuffix"
287246
def tasksOf(name: String): Vector[String] = projects.map(project => s"$project/$name")
288247

289248
val tasks = if (isJVM) {
290249
clean ++
291250
withCoverage((tasksOf("compile") ++ tasksOf("test") ++ tasksOf("coverageReport")).toSeq *) ++
292-
Vector("benchmarks/compile") ++
251+
Vector("benchmarks2_13/compile") ++ // benchmarks is Scala 2.13 / JVM only
293252
tasksOf("mimaReportBinaryIssues")
294253
} else {
295254
clean ++ tasksOf("test")
@@ -301,12 +260,9 @@ val ciCommand = (platform: String, scalaSuffix: String) => {
301260
val publishLocalForTests = {
302261
val jvm = for {
303262
module <- Vector("chimney", "chimneyCats", "chimneyProtobufs")
304-
moduleVersion <- Vector(module, module + "3")
305-
} yield moduleVersion + "/publishLocal"
306-
val js = for {
307-
module <- Vector("chimney").map(_ + "JS")
308-
moduleVersion <- Vector(module)
309-
} yield moduleVersion + "/publishLocal"
263+
cellScalaSuffix <- Vector("2_13", "") // Scala 2.13 then Scala 3
264+
} yield s"$module$cellScalaSuffix/publishLocal"
265+
val js = Vector("chimneyJS2_13/publishLocal") // Scala 2.13 / JS
310266
jvm ++ js
311267
}.mkString(" ; ")
312268

@@ -338,10 +294,10 @@ lazy val root = project
338294
| - Scala JVM adds no suffix to a project name seen in build.sbt
339295
| - Scala.js adds the "JS" suffix to a project name seen in build.sbt
340296
| - Scala Native adds the "Native" suffix to a project name seen in build.sbt
341-
| - Scala 2.13 adds no suffix to a project name seen in build.sbt
342-
| - Scala 3 adds the suffix "3" to a project name seen in build.sbt
297+
| - Scala 3 adds no suffix to a project name seen in build.sbt
298+
| - Scala 2.13 adds the suffix "2_13" to a project name seen in build.sbt (sbt 2.x flipped the sbt 1.x scheme)
343299
|
344-
|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.
300+
|When working with IntelliJ or Scala Metals, edit "ide.scala"/"ide.platform" in dev.properties (read by `dev` in project/BuildVersions.scala) to control which Scala version you're currently working with.
345301
|
346302
|If you need to test library locally in a different project, use publish-local-for-tests or manually publishLocal:
347303
| - chimney
@@ -356,8 +312,8 @@ lazy val root = project
356312
"Compile and test all projects in all Scala versions and platforms (beware! it uses a lot of memory and might OOM!)"
357313
)
358314
.noAlias,
359-
sbtwelcome.UsefulTask("chimney3/console", "Drop into REPL with Chimney DSL imported (3)").noAlias,
360-
sbtwelcome.UsefulTask("chimney/console", "Drop into REPL with Chimney DSL imported (2.13)").noAlias,
315+
sbtwelcome.UsefulTask("chimney/console", "Drop into REPL with Chimney DSL imported (3)").noAlias,
316+
sbtwelcome.UsefulTask("chimney2_13/console", "Drop into REPL with Chimney DSL imported (2.13)").noAlias,
361317
sbtwelcome
362318
.UsefulTask(releaseCommand(git.gitCurrentTags.value), "Publish everything to release or snapshot repository")
363319
.alias("ci-release"),
@@ -400,9 +356,9 @@ lazy val chimney = projectMatrix
400356
for3 = Seq("-skip-by-regex:io\\.scalaland\\.chimney\\.internal"),
401357
for2_13 = Seq("-skip-packages", "io.scalaland.chimney.internal")
402358
),
403-
libraryDependencies += "com.kubuszok" %%% "hearth" % versions.hearth,
359+
libraryDependencies += "com.kubuszok" %% "hearth" % versions.hearth,
404360
// ChimneySpec is based on hearth-munit's MacroSuite (group/==>/compileErrors-check utilities).
405-
libraryDependencies += "com.kubuszok" %%% "hearth-munit" % versions.hearth % Test,
361+
libraryDependencies += "com.kubuszok" %% "hearth-munit" % versions.hearth % Test,
406362
// Cross-quotes: on Scala 2 they are macros (part of hearth), on Scala 3 they are a compiler plugin.
407363
libraryDependencies ++= versions.fold(scalaVersion.value)(
408364
for2_13 = Seq.empty,
@@ -433,7 +389,7 @@ lazy val chimneyEngineTestExtension = projectMatrix
433389
name := "chimney-engine-test-extension",
434390
description := "Test-only Hearth StandardMacroExtension used by chimney's engine test suites",
435391
mimaFailOnNoPrevious := false, // this module is not published
436-
libraryDependencies += "com.kubuszok" %%% "hearth" % versions.hearth,
392+
libraryDependencies += "com.kubuszok" %% "hearth" % versions.hearth,
437393
// Cross-quotes: on Scala 2 they are macros (part of hearth), on Scala 3 they are a compiler plugin.
438394
libraryDependencies ++= versions.fold(scalaVersion.value)(
439395
for2_13 = Seq.empty,
@@ -460,7 +416,7 @@ lazy val chimneyChimneyExtensionTest = projectMatrix
460416
name := "chimney-chimney-extension-test",
461417
description := "Test-only Chimney ChimneyMacroExtension used to prove the engine-aware macro-extension SPI",
462418
mimaFailOnNoPrevious := false, // this module is not published
463-
libraryDependencies += "com.kubuszok" %%% "hearth" % versions.hearth,
419+
libraryDependencies += "com.kubuszok" %% "hearth" % versions.hearth,
464420
// Cross-quotes: on Scala 2 they are macros (part of hearth), on Scala 3 they are a compiler plugin.
465421
libraryDependencies ++= versions.fold(scalaVersion.value)(
466422
for2_13 = Seq.empty,
@@ -486,13 +442,13 @@ lazy val chimneyCats = projectMatrix
486442
.settings(dependencies *)
487443
.settings(
488444
Compile / console / initialCommands := "import io.scalaland.chimney.*, io.scalaland.chimney.dsl.*, io.scalaland.chimney.cats.*",
489-
libraryDependencies += "org.typelevel" %%% "cats-core" % versions.cats,
490-
libraryDependencies += "org.typelevel" %%% "cats-laws" % versions.cats % Test,
445+
libraryDependencies += "org.typelevel" %% "cats-core" % versions.cats,
446+
libraryDependencies += "org.typelevel" %% "cats-laws" % versions.cats % Test,
491447
// Since 2.0.0 chimney-cats also ships a Chimney `ChimneyMacroExtension` (ServiceLoader-registered, see
492448
// src/main/resources/META-INF/services): engine-aware SpecialCaseHandlers restoring the total NonEmpty<->NonEmpty
493449
// (Traverse), NonEmptyMap/NonEmptySet and FunctionK conversions that used to live as `CatsDataImplicits`. The
494450
// handlers use Hearth's API + cross-quotes directly (hearth itself already comes transitively through chimney).
495-
libraryDependencies += "com.kubuszok" %%% "hearth" % versions.hearth,
451+
libraryDependencies += "com.kubuszok" %% "hearth" % versions.hearth,
496452
// Cross-quotes: on Scala 2 they are macros (part of hearth), on Scala 3 they are a compiler plugin.
497453
libraryDependencies ++= versions.fold(scalaVersion.value)(
498454
for2_13 = Seq.empty,
@@ -505,7 +461,7 @@ lazy val chimneyCats = projectMatrix
505461
// build with Scala 3.8+ (older compilers throw "Forward incompatible TASTy file" from hearth's extension loading).
506462
// Since hearth#325 (0.4.1) an unloadable extension jar is SKIPPED gracefully instead of poisoning every derivation
507463
// in the module - but the specs here obviously still need the extension to actually load.
508-
libraryDependencies += "com.kubuszok" %%% "kindlings-cats-integration" % versions.kindlingsCatsIntegration % Test
464+
libraryDependencies += "com.kubuszok" %% "kindlings-cats-integration" % versions.kindlingsCatsIntegration % Test
509465
)
510466
.dependsOn(chimney % s"$Test->$Test;$Compile->$Compile")
511467

@@ -539,7 +495,7 @@ lazy val chimneyProtobufs = projectMatrix
539495
.Settings(
540496
// Scala.js and Scala Native decided to not implement java.time and let an external library do it,
541497
// meanwhile we want to provide some type class instances for types in java.time.
542-
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % versions.scalaJavaTime
498+
libraryDependencies += "io.github.cquiroz" %% "scala-java-time" % versions.scalaJavaTime
543499
)) *
544500
)
545501
.enablePlugins(GitVersioning, GitBranchPrompt)
@@ -567,7 +523,7 @@ lazy val chimneyProtobufs = projectMatrix
567523
// replaced the corresponding implicits, so those conversions work WITHOUT any import once this jar is on the
568524
// classpath. The providers use Hearth's API + cross-quotes directly, hence the explicit dependencies below
569525
// (hearth itself already comes transitively through the chimney module).
570-
libraryDependencies += "com.kubuszok" %%% "hearth" % versions.hearth,
526+
libraryDependencies += "com.kubuszok" %% "hearth" % versions.hearth,
571527
// Cross-quotes: on Scala 2 they are macros (part of hearth), on Scala 3 they are a compiler plugin.
572528
libraryDependencies ++= versions.fold(scalaVersion.value)(
573529
for2_13 = Seq.empty,
@@ -625,7 +581,11 @@ lazy val chimneySandwichTests = projectMatrix
625581
moduleName := "chimney-sandwich-tests",
626582
name := "chimney-sandwich-tests",
627583
description := "Tests macros in 2.13x3 cross-compilation",
628-
mimaFailOnNoPrevious := false // this module is not published
584+
mimaFailOnNoPrevious := false, // this module is not published
585+
// This module IS the 2.13x3 sandwich: each cell depends on a test-cases fixture built with the OTHER Scala version
586+
// (Scala 3 cell -> chimney-sandwich-test-cases-213, Scala 2.13 cell -> chimney-sandwich-test-cases-3). sbt 2.x
587+
// rejects a cross-Scala projectDependency by default; opt in since the mismatch is the whole point here.
588+
allowMismatchScala := true
629589
)
630590
.dependsOn(chimney % s"$Test->$Test;$Compile->$Compile")
631591
.dependsOn(chimneySandwichTestCases213 % s"$Test->$Test;$Compile->$Compile")

project/BuildVersions.scala

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import sbt.*
2+
import sbt.librarymanagement.CrossVersion
3+
4+
// Build-level version/axis config (`versions`) and IDE dev settings (`dev`). These live in project/*.scala rather
5+
// than build.sbt because sbt 2.x compiles build.sbt with Scala 3, which (a) widens a build.sbt-local
6+
// `val x = new { ... }` to `Object` and hides its members, and (b) does not bring a build.sbt-local `object`/`class`
7+
// into the settings scope. As real objects on the meta-build classpath they are visible in build.sbt unqualified
8+
// (`versions.scala3`, `dev.idePlatform`, ...), exactly as before the sbt 2 migration.
9+
10+
object versions {
11+
// Versions we are publishing for.
12+
val scala213 = "2.13.18"
13+
val scala3 = "3.8.4"
14+
// For chimney-sandwich-test-cases-3 ONLY: sbt forbids Scala 2.13 subprojects from depending on Scala 3.8+
15+
// subprojects (sbt-8728), and 2.13's -Ytasty-reader tops out below TASTy 28.8 - see the module for details.
16+
val scala3Sandwich = "3.7.3"
17+
18+
// Which versions should be cross-compiled for publishing
19+
val scalas = List(scala213, scala3)
20+
21+
val platforms = List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native)
22+
23+
// Dependencies.
24+
val hearth = "0.4.1"
25+
val cats = "2.13.0"
26+
// kindlings 0.3.1 is the first release on hearth 0.4.1 and includes kubuszok/kindlings#163
27+
// (NonEmptySeq/NonEmptyLazyList IsCollection providers).
28+
val kindlingsCatsIntegration = "0.3.1"
29+
val kindProjector = "0.13.4"
30+
val munit = "1.3.4"
31+
val scalaCollectionCompat = "2.14.0"
32+
val scalaJavaCompat = "1.0.2"
33+
val scalaJavaTime = "2.7.0"
34+
val scalapbRuntime = scalapb.compiler.Version.scalapbVersion
35+
36+
// Explicitly handle Scala 2.13 and Scala 3 separately.
37+
def fold[A](scalaVersion: String)(for2_13: => Seq[A], for3: => Seq[A]): Seq[A] =
38+
CrossVersion.partialVersion(scalaVersion) match {
39+
case Some((2, 13)) => for2_13
40+
case Some((3, _)) => for3
41+
case _ => Seq.empty // for sbt
42+
}
43+
}
44+
45+
object dev {
46+
47+
val props = scala.util
48+
.Using(new java.io.FileInputStream("dev.properties")) { fis =>
49+
val props = new java.util.Properties()
50+
props.load(fis)
51+
props
52+
}
53+
.get
54+
55+
// Which version should be used in IntelliJ
56+
val ideScala = props.getProperty("ide.scala") match {
57+
case "2.13" => versions.scala213
58+
case "3" => versions.scala3
59+
}
60+
val idePlatform = props.getProperty("ide.platform") match {
61+
case "jvm" => VirtualAxis.jvm
62+
case "js" => VirtualAxis.js
63+
case "native" => VirtualAxis.native
64+
}
65+
66+
def isIdeScala(scalaVersion: String): Boolean =
67+
CrossVersion.partialVersion(scalaVersion) == CrossVersion.partialVersion(ideScala)
68+
def isIdePlatform(platform: VirtualAxis): Boolean = platform == idePlatform
69+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.12.13
1+
sbt.version=2.0.2

0 commit comments

Comments
 (0)