-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
build.sbt
328 lines (287 loc) · 11 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
ThisBuild / tlBaseVersion := "2.12"
val scalaCheckVersion = "1.18.1"
val disciplineVersion = "1.7.0"
val disciplineMunitVersion = "2.0.0"
val munitVersion = "1.0.2"
val PrimaryJava = JavaSpec.temurin("8")
val LTSJava = JavaSpec.temurin("17")
val GraalVM = JavaSpec.graalvm("21")
ThisBuild / githubWorkflowJavaVersions := Seq(PrimaryJava, LTSJava, GraalVM)
val Scala212 = "2.12.20"
val Scala213 = "2.13.15"
val Scala3 = "3.3.4"
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / scalaVersion := Scala213
ThisBuild / tlFatalWarnings := false
ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
"scalafix",
"Scalafix",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep.Run(List("cd scalafix", "sbt test"), name = Some("Scalafix tests"))
),
javas = List(PrimaryJava),
scalas = Nil
)
)
lazy val macroSettings = Seq(
libraryDependencies ++= {
if (tlIsScala3.value)
Nil
else
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided)
}
)
lazy val cats1BincompatSettings = Seq(
tlMimaPreviousVersions ++= {
if (scalaVersion.value.startsWith("2.12")) Set("1.0.1", "1.1.0", "1.2.0", "1.3.1", "1.4.0", "1.5.0", "1.6.1")
else Set.empty
}
)
ThisBuild / tlVersionIntroduced := Map("3" -> "2.6.1")
lazy val commonJvmSettings = Seq(
Test / fork := true,
Test / javaOptions := Seq("-Xmx3G"),
doctestGenTests := { if (tlIsScala3.value) Nil else doctestGenTests.value }
)
lazy val commonJsSettings = Seq(
doctestGenTests := Seq.empty,
tlVersionIntroduced ++= List("2.12", "2.13").map(_ -> "2.1.0").toMap
)
Global / concurrentRestrictions += Tags.limit(NativeTags.Link, 1)
// Cats 2.12.0 switches to Scala Native 0.5.
// Therefore `tlVersionIntroduced` should be reset to 2.12.0 for all scala versions in all native cross-projects.
val commonNativeTlVersionIntroduced = List("2.12", "2.13", "3").map(_ -> "2.12.0").toMap
lazy val commonNativeSettings = Seq[Setting[?]](
doctestGenTests := Seq.empty,
tlVersionIntroduced := commonNativeTlVersionIntroduced
)
lazy val disciplineDependencies = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-core" % disciplineVersion
)
)
lazy val testingDependencies = Seq(
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test
)
)
lazy val cats = tlCrossRootProject
.aggregate(
kernel,
kernelLaws,
algebra,
algebraLaws,
core,
laws,
free,
testkit,
tests,
alleycatsCore,
alleycatsLaws,
unidocs,
bench,
binCompatTest
)
lazy val kernel = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("kernel"))
.settings(moduleName := "cats-kernel", name := "Cats kernel")
.settings(testingDependencies)
.settings(Compile / sourceGenerators += (Compile / sourceManaged).map(KernelBoiler.gen).taskValue)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings, cats1BincompatSettings)
.nativeSettings(commonNativeSettings)
lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("kernel-laws"))
.dependsOn(kernel)
.settings(moduleName := "cats-kernel-laws", name := "Cats kernel laws")
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val algebraSettings = Seq[Setting[?]](
tlMimaPreviousVersions += "2.2.3",
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "2.7.0").toMap
)
lazy val algebraNativeSettings = Seq[Setting[?]](
// Reset to auto-populate from `tlVersionIntroduced` below.
tlMimaPreviousVersions := Set.empty,
// Should be reset to the common setting value, because `algebraSettings` re-defines it.
tlVersionIntroduced := commonNativeTlVersionIntroduced
)
lazy val algebra = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("algebra-core"))
.dependsOn(kernel)
.settings(moduleName := "algebra", name := "Cats algebra", scalacOptions -= "-Xsource:3")
.settings(Compile / sourceGenerators += (Compile / sourceManaged).map(AlgebraBoilerplate.gen).taskValue)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
.settings(
algebraSettings,
libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test,
testingDependencies
)
.nativeSettings(algebraNativeSettings)
lazy val algebraLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("algebra-laws"))
.dependsOn(kernelLaws, algebra)
.settings(moduleName := "algebra-laws", name := "Cats algebra laws", scalacOptions -= "-Xsource:3")
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
.settings(algebraSettings)
.nativeSettings(algebraNativeSettings)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(kernel)
.settings(moduleName := "cats-core", name := "Cats core")
.settings(macroSettings)
.settings(Compile / sourceGenerators += (Compile / sourceManaged).map(Boilerplate.gen).taskValue)
.settings(
libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test
)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings, cats1BincompatSettings)
.nativeSettings(commonNativeSettings)
lazy val laws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(kernel, core, kernelLaws)
.settings(moduleName := "cats-laws", name := "Cats laws")
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val free = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(core, tests % "test-internal -> test")
.settings(moduleName := "cats-free", name := "Cats Free")
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings, cats1BincompatSettings)
.nativeSettings(commonNativeSettings)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.dependsOn(testkit % Test)
.enablePlugins(NoPublishPlugin)
.settings(moduleName := "cats-tests")
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val testkit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(core, laws)
.enablePlugins(BuildInfoPlugin)
.settings(buildInfoKeys := Seq[BuildInfoKey](scalaVersion), buildInfoPackage := "cats.tests")
.settings(moduleName := "cats-testkit")
.settings(disciplineDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val alleycatsCore = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("alleycats-core"))
.dependsOn(core)
.settings(moduleName := "alleycats-core", name := "Alleycats core")
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val alleycatsLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("alleycats-laws"))
.dependsOn(alleycatsCore, laws, tests % "test-internal -> test")
.settings(moduleName := "alleycats-laws", name := "Alleycats laws")
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)
lazy val unidocs = project
.enablePlugins(TypelevelUnidocPlugin)
.settings(
name := "cats-docs",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(kernel.jvm,
kernelLaws.jvm,
core.jvm,
laws.jvm,
free.jvm,
algebra.jvm,
algebraLaws.jvm,
alleycatsCore.jvm,
alleycatsLaws.jvm,
testkit.jvm
),
ScalaUnidoc / unidoc / scalacOptions ++= Seq("-groups", "-diagrams")
)
// bench is currently JVM-only
lazy val bench = project
.dependsOn(core.jvm, free.jvm, laws.jvm)
.settings(moduleName := "cats-bench")
.settings(commonJvmSettings)
.settings(
evictionErrorLevel := Level.Warn
)
.enablePlugins(NoPublishPlugin, JmhPlugin)
lazy val binCompatTest = project
.enablePlugins(NoPublishPlugin)
.settings(
useCoursier := false, // workaround so we can use an old version in compile
libraryDependencies += {
val oldV = if (tlIsScala3.value) "2.6.1" else "2.0.0"
"org.typelevel" %%% "cats-core" % oldV % Provided
}
)
.settings(testingDependencies)
.dependsOn(core.jvm % Test)
lazy val docs = project
.in(file("site"))
.enablePlugins(TypelevelSitePlugin)
.settings(
tlFatalWarnings := false,
mdocVariables += ("API_LINK_BASE" -> s"https://www.javadoc.io/doc/org.typelevel/cats-docs_2.13/${mdocVariables
.value("VERSION")}/"),
laikaConfig := {
import laika.config._
laikaConfig.value.withRawContent
.withConfigValue("version", mdocVariables.value("VERSION"))
.withConfigValue(
LinkConfig.empty
.addApiLinks(
ApiLinks(s"https://www.javadoc.io/doc/org.typelevel/cats-docs_2.13/${mdocVariables.value("VERSION")}/"),
ApiLinks(s"https://www.scala-lang.org/api/$Scala213/").withPackagePrefix("scala")
)
)
},
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion
)
)
.dependsOn(core.jvm, free.jvm, laws.jvm)
ThisBuild / licenses := List(License.MIT)
ThisBuild / startYear := Some(2015)
ThisBuild / developers ++= List(
tlGitHubDev("ceedubs", "Cody Allen"),
tlGitHubDev("rossabaker", "Ross Baker"),
tlGitHubDev("armanbilge", "Arman Bilge"),
tlGitHubDev("johnynek", "P. Oscar Boykin"),
tlGitHubDev("travisbrown", "Travis Brown"),
tlGitHubDev("adelbertc", "Adelbert Chang"),
tlGitHubDev("danicheg", "Daniel Esik"),
tlGitHubDev("peterneyens", "Peter Neyens"),
tlGitHubDev("tpolecat", "Rob Norris"),
tlGitHubDev("non", "Erik Osheim"),
tlGitHubDev("LukaJCB", "LukaJCB"),
tlGitHubDev("mpilquist", "Michael Pilquist"),
tlGitHubDev("milessabin", "Miles Sabin"),
tlGitHubDev("djspiewak", "Daniel Spiewak"),
tlGitHubDev("fthomas", "Frank Thomas"),
tlGitHubDev("satorg", "Sergey Torgashov"),
tlGitHubDev("julien-truffaut", "Julien Truffaut"),
tlGitHubDev("kailuowang", "Kailuo Wang")
)