-
Notifications
You must be signed in to change notification settings - Fork 49
/
build.sbt
315 lines (274 loc) · 9.51 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
import WeaverPlugin._
ThisBuild / commands += Command.command("ci") { state =>
"versionDump" ::
"scalafmtCheckAll" ::
"scalafix --check" ::
"Test/scalafix --check" ::
"clean" ::
"Test/compile" ::
"Test/fastLinkJS" :: // do this separately as it's memory intensive
"test" ::
"docs/docusaurusCreateSite" ::
"core/publishLocal" :: state
}
ThisBuild / commands += Command.command("fix") { state =>
"scalafix" ::
"Test/scalafix" ::
"scalafmtAll" ::
"scalafmtSbt" :: state
}
ThisBuild / commands += Command.command("release") { state =>
"publishSigned" ::
"sonatypeBundleRelease" :: state
}
ThisBuild / commands ++= createBuildCommands(allModules)
ThisBuild / scalaVersion := WeaverPlugin.scala213
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
Global / (Test / fork) := true
Global / (Test / testOptions) += Tests.Argument("--quickstart")
sonatypeCredentialHost := "s01.oss.sonatype.org"
val Version = new {
object CE3 {
val fs2 = "3.5.0"
val ce = "3.5.3"
}
val expecty = "0.16.0"
val portableReflect = "1.1.2"
val junit = "4.13.2"
val scalajsStubs = "1.1.0"
val discipline = "1.5.1"
val catsLaws = "2.9.0"
val scalacheck = "1.17.0"
val testInterface = "1.0"
val scalaJavaTime = "2.4.0"
val scalajsMacroTask = "1.1.1"
}
lazy val root = project
.in(file("."))
.aggregate(allModules: _*)
.settings(WeaverPlugin.doNotPublishArtifact)
lazy val allModules = Seq(
core.projectRefs,
framework.projectRefs,
scalacheck.projectRefs,
discipline.projectRefs,
intellijRunner.projectRefs,
effectCores,
effectFrameworks
).flatten
def catsEffectDependencies(proj: Project): Project = {
proj.settings(
libraryDependencies ++=
Seq(
"co.fs2" %%% "fs2-core" % Version.CE3.fs2,
"org.typelevel" %%% "cats-effect" % Version.CE3.ce
)
)
}
lazy val core = projectMatrix
.in(file("modules/core"))
.settings(WeaverPlugin.simpleLayout)
.full
.configure(catsEffectDependencies)
.settings(
libraryDependencies ++= Seq(
"com.eed3si9n.expecty" %%% "expecty" % Version.expecty,
// https://github.com/portable-scala/portable-scala-reflect/issues/23
"org.portable-scala" %%% "portable-scala-reflect" % Version.portableReflect cross CrossVersion.for3Use2_13
),
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm))
Seq(
"org.scala-js" %%% "scalajs-stubs" % Version.scalajsStubs % "provided" cross CrossVersion.for3Use2_13,
"junit" % "junit" % Version.junit % Optional
)
else Seq.empty
},
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm)) {
if (scalaVersion.value.startsWith("3."))
Seq("org.scala-lang" % "scala-reflect" % scala213)
else
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
} else Seq.empty
}
)
lazy val projectsWithAxes = Def.task {
(name.value, virtualAxes.value, version.value)
}
val allEffectCoresFilter: ScopeFilter =
ScopeFilter(
inProjects(effectFrameworks: _*),
inConfigurations(Compile)
)
val allIntegrationsCoresFilter: ScopeFilter =
ScopeFilter(
inProjects(
(scalacheck.projectRefs ++ discipline.projectRefs): _*),
inConfigurations(Compile)
)
lazy val docs = projectMatrix
.in(file("modules/docs"))
.jvmPlatform(Seq(WeaverPlugin.scala213))
.enablePlugins(DocusaurusPlugin, MdocPlugin)
.dependsOn(core, scalacheck, cats, discipline)
.settings(
moduleName := "docs",
watchSources += (ThisBuild / baseDirectory).value / "docs",
mdocVariables := Map(
"VERSION" -> version.value
),
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-dsl" % "0.23.12",
"org.http4s" %% "http4s-blaze-server" % "0.23.12",
"org.http4s" %% "http4s-blaze-client" % "0.23.12",
"com.lihaoyi" %% "fansi" % "0.2.7",
"org.typelevel" %% "cats-kernel-laws" % "2.8.0"
),
Compile / sourceGenerators += Def.taskDyn {
val filePath =
(Compile / sourceManaged).value / "BuildMatrix.scala"
def q(s: String) = '"' + s + '"'
def process(f: Iterable[(String, Seq[VirtualAxis], String)]) = f.map {
case (name, axes, ver) =>
val isJVM = axes.contains(VirtualAxis.jvm)
val isJS = axes.contains(VirtualAxis.js)
val scalaVersion = axes.collectFirst {
case a: VirtualAxis.ScalaVersionAxis => a
}.get.scalaVersion
List(
s"name = ${q(name)}",
s"jvm = $isJVM",
s"js = $isJS",
s"scalaVersion = ${q(scalaVersion)}",
s"version = ${q(ver)}"
).mkString("Artifact(", ",", ")")
}.mkString("List(", ",\n", ")")
val effects = process(projectsWithAxes.all(allEffectCoresFilter).value)
val integrations =
process(projectsWithAxes.all(allIntegrationsCoresFilter).value)
val artifactsCE3Version = (cats.jvm(scala213) / version).value
IO.write(
filePath,
s"""
| package weaver.docs
|
| object BuildMatrix {
| val catsEffect3Version = ${q(Version.CE3.ce)}
| val artifactsCE3Version = ${q(artifactsCE3Version)}
| val effects = $effects
| val integrations = $integrations
| }
""".stripMargin
)
Def.task(Seq(filePath))
}
)
lazy val framework = projectMatrix
.in(file("modules/framework"))
.dependsOn(core)
.full
.settings(
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm))
Seq(
"org.scala-sbt" % "test-interface" % Version.testInterface,
"org.scala-js" %%% "scalajs-stubs" % Version.scalajsStubs % "provided" cross CrossVersion.for3Use2_13
)
else if (virtualAxes.value.contains(VirtualAxis.js))
Seq(
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion cross CrossVersion.for3Use2_13
)
else if (virtualAxes.value.contains(VirtualAxis.native))
Seq(
"org.scala-native" %%% "test-interface" % nativeVersion
)
else Seq.empty
} ++ Seq("junit" % "junit" % Version.junit)
)
.settings(WeaverPlugin.simpleLayout)
lazy val scalacheck = projectMatrix
.in(file("modules/scalacheck"))
.full
.dependsOn(core, cats % "test->compile")
.settings(WeaverPlugin.simpleLayout)
.settings(
testFrameworks := Seq(new TestFramework("weaver.framework.CatsEffect")),
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % Version.scalacheck,
"org.typelevel" %%% "cats-effect-testkit" % Version.CE3.ce % Test)
)
lazy val discipline = projectMatrix
.in(file("modules/discipline"))
.full
.dependsOn(core, cats)
.settings(
name := "discipline",
testFrameworks := Seq(new TestFramework("weaver.framework.CatsEffect")),
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-core" % Version.discipline,
"org.typelevel" %%% "cats-laws" % Version.catsLaws % Test
)
)
.settings(WeaverPlugin.simpleLayout)
// #################################################################################################
// Effect-specific cores
// #################################################################################################
lazy val effectCores: Seq[ProjectReference] =
coreCats.projectRefs
lazy val coreCats = projectMatrix
.in(file("modules/core/cats"))
.full
.dependsOn(core)
.settings(WeaverPlugin.simpleLayout)
.settings(scalaJSMacroTask)
.settings(name := "cats-core")
// #################################################################################################
// Effect-specific frameworks
// #################################################################################################
lazy val effectFrameworks: Seq[ProjectReference] = cats.projectRefs
lazy val cats = projectMatrix
.in(file("modules/framework/cats"))
.dependsOn(framework, coreCats)
.full
.settings(WeaverPlugin.simpleLayout)
.settings(
name := "cats",
testFrameworks := Seq(new TestFramework("weaver.framework.CatsEffect"))
)
// #################################################################################################
// Intellij
// #################################################################################################
lazy val intellijRunner = projectMatrix
.sparse(withJS = false, withScala3 = false)
.in(file("modules/intellij-runner"))
.dependsOn(core, framework, framework % "test->compile")
.settings(WeaverPlugin.simpleLayout)
.settings(
name := "intellij-runner"
)
// #################################################################################################
// Misc
// #################################################################################################
lazy val versionDump =
taskKey[Unit]("Dumps the version in a file named version")
versionDump := {
val file = (ThisBuild / baseDirectory).value / "version"
IO.write(file, (Compile / version).value)
}
ThisBuild / concurrentRestrictions ++= {
if (!sys.env.contains("CI")) {
Seq(
Tags.limitAll(4),
Tags.limit(ScalaJSPlugin.autoImport.ScalaJSTags.Link, 1)
)
} else Seq.empty
}
lazy val scalaJSMacroTask: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.js))
Seq("org.scala-js" %%% "scala-js-macrotask-executor" % Version.scalajsMacroTask)
else
Seq.empty
}
)