-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sbt
More file actions
194 lines (175 loc) · 7.4 KB
/
Copy pathbuild.sbt
File metadata and controls
194 lines (175 loc) · 7.4 KB
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
import commandmatrix.extra.*
import kubuszok.sbt._
import kubuszok.sbt.KubuszokPlugin.autoImport._
// Versions
// sbt 2.0's build dialect drops the structural-type refinement on `new { ... }`, so `versions.scala3`
// fails to resolve, and top-level objects aren't visible to lifted setting expressions either.
// Use plain top-level vals (the proven sbt-2.0 pattern).
val scala3 = "3.8.4"
val scalas = List(scala3)
val platforms = List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native)
// Dependencies (test)
// munit 1.3.3+: avoids the scala-native test-interface eviction with scala-native 0.5.12 on sbt 2.0.
val munitVersion = "1.3.4"
val munitScalacheckVersion = "1.3.0"
val scalacheckVersion = "1.19.0"
val dev = new DevProperties(
scala213 = None,
scala3 = Some(scala3),
platforms = platforms
)
lazy val al = new Aliases(
published = Seq(lls, `lls-io`),
compileOnly = Seq(`lls-bench`)
)
// CI/test command aliases (e.g. ci-jvm-3, test-js-3, test-native-3), consumed by .github/workflows/ci.yml.
// sbt-welcome used to register these via `usefulTasks`, but it has no sbt 2.0 build, so we register
// them directly from the Aliases helper bundled with sbt-kubuszok.
def aliasName(prefix: String, platform: String, scalaBinary: String): String =
s"$prefix-${platform.toLowerCase}-${scalaBinary.replace('.', '_')}"
// In sbt 2.0 the `test` task is incremental and machine-wide cached (it behaves like sbt 1.x's
// `testQuick`), so a CI run that begins with `clean` can still report "No tests to run" and pass
// vacuously. `testFull` is the uncached full run. Rewrite the generated `<id>/test` steps to
// `<id>/testFull` so CI always executes the whole suite.
def fullTests(command: String): String =
command
.split(";")
.map { step =>
val trimmed = step.trim
if (trimmed.endsWith("/test")) trimmed.stripSuffix("/test") + "/testFull" else trimmed
}
.mkString(" ; ")
lazy val ciAliases: Seq[Def.Setting[?]] = {
val platformNames = List("JVM", "JS", "Native")
val scalaBinaries = List("3")
val perCombination = for {
platform <- platformNames
scalaBinary <- scalaBinaries
setting <-
addCommandAlias(aliasName("ci", platform, scalaBinary), fullTests(al.ci(platform, scalaBinary))) ++
addCommandAlias(aliasName("test", platform, scalaBinary), fullTests(al.test(platform, scalaBinary)))
} yield setting
perCombination ++ addCommandAlias("ci-release", al.release)
}
val commonSettings = Seq(
MatrixAction.ForAll.Configure(_.settings(
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-no-indent",
"-Werror",
"-Wimplausible-patterns",
"-Wrecurse-with-default",
"-Wenum-comment-discard",
"-Wunused:imports,privates,locals,patvars,nowarn",
"-Wconf:cat=deprecation:info"
),
testFrameworks += new TestFramework("munit.Framework")
)),
MatrixAction.ForPlatforms(VirtualAxis.jvm).Configure(_.settings(
fork := true,
Test / unmanagedSourceDirectories += (Test / sourceDirectory).value / "scalajvm",
// sbt 2.0 + scoverage + `fork := true`: the scoverage runtime Invoker in the *forked* test JVM
// writes per-thread measurement files into `<crossTarget>/scoverage-data`, but on sbt 2.0 that
// directory is no longer pre-created in-process before the fork starts, so every instrumented
// test crashes with `FileNotFoundException: .../scoverage-data/scoverage.measurements.*`. Ensure
// the directory exists; piggy-back on Test/compile, which every test task depends on. Harmless
// when coverage is off (the dir just stays empty).
Test / compile := Def.uncached {
val analysis = (Test / compile).value
IO.createDirectory((Test / crossTarget).value / "scoverage-data")
analysis
}
)),
// Scala Native 0.5.12: munit 1.3.3 pulls test-interface 0.5.12 while scalacheck 1.19.0 still pulls
// 0.5.8. Coursier already selects 0.5.12 (the newer toolchain version), but the Scala Native
// plugin marks test-interface with a "strict" scheme, so the older request is reported as a
// binary-incompat eviction error on sbt 2.0. Demote that eviction to a warning for native.
MatrixAction.ForPlatforms(VirtualAxis.native).Configure(_.settings(
evictionErrorLevel := sbt.util.Level.Warn
))
)
val publishSettings = Seq(
organization := "com.kubuszok",
homepage := Some(url("https://github.com/kubuszok/lls")),
organizationHomepage := Some(url("https://kubuszok.com")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(
ScmInfo(
url("https://github.com/kubuszok/lls/"),
"scm:git:git@github.com:kubuszok/lls.git"
)
),
startYear := Some(2025),
developers := List(
Developer("MateuszKubuszok", "Mateusz Kubuszok", "", url("https://kubuszok.com"))
),
pomExtra := (
<issueManagement>
<system>GitHub issues</system>
<url>https://github.com/kubuszok/lls/issues</url>
</issueManagement>
),
projectType := ProjectType.ScalaLibrary
)
val noPublishSettings =
Seq(projectType := ProjectType.NonPublished)
val mimaSettings = Seq(
mimaPreviousArtifacts := Set(),
mimaFailOnNoPrevious := false
)
// --- Modules ---
lazy val lls = (projectMatrix in file("lls"))
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaABIVersion(scala3))
.someVariations(scalas, platforms)((commonSettings ++ dev.only1VersionInIDE) *)
.settings(
name := "lls",
description := "Low Level Scala — cross-platform, allocation-conscious utilities",
libraryDependencies ++= Seq(
// sbt 2.0: %% is platform-aware (encodes Scala version + JS/Native suffix); %%% is gone.
"org.scalameta" %% "munit" % munitVersion % Test,
"org.scalameta" %% "munit-scalacheck" % munitScalacheckVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test
)
)
.settings(publishSettings)
.settings(mimaSettings)
lazy val `lls-io` = (projectMatrix in file("lls-io"))
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaABIVersion(scala3))
.someVariations(scalas, platforms)((commonSettings ++ dev.only1VersionInIDE) *)
.settings(
name := "lls-io",
description := "Low Level Scala — cross-platform immutable POSIX-string file paths and file operations",
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % munitVersion % Test,
"org.scalameta" %% "munit-scalacheck" % munitScalacheckVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test
)
)
.settings(publishSettings)
.settings(mimaSettings)
lazy val `lls-bench` = (projectMatrix in file("lls-bench"))
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaABIVersion(scala3))
.enablePlugins(JmhPlugin)
.someVariations(scalas, List(VirtualAxis.jvm))((commonSettings ++ dev.only1VersionInIDE) *)
.settings(
name := "lls-bench",
description := "JMH benchmarks for Low Level Scala",
scalacOptions --= Seq("-Wunused:imports,privates,locals,patvars,nowarn")
)
.settings(noPublishSettings)
.settings(mimaSettings)
.dependsOn(lls)
// --- Root ---
lazy val root = (project in file("."))
.enablePlugins(KubuszokRootPlugin)
.aggregate(lls.projectRefs *)
.aggregate(`lls-io`.projectRefs *)
.aggregate(`lls-bench`.projectRefs *)
.settings(
name := "lls-build",
description := "Build setup for Low Level Scala"
)
.settings(ciAliases)
.settings(noPublishSettings)
.settings(mimaSettings)