generated from indoorvivants/scala3-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
209 lines (187 loc) · 5.72 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
import scala.io.StdIn
Global / excludeLintKeys += logManager
Global / excludeLintKeys += scalaJSUseMainModuleInitializer
Global / excludeLintKeys += scalaJSLinkerConfig
inThisBuild(
List(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalafixScalaBinaryVersion := scalaBinaryVersion.value,
organization := "tech.neander",
organizationName := "Neandertech",
sonatypeCredentialHost := "s01.oss.sonatype.org",
resolvers ++= Resolver.sonatypeOssRepos("releases"),
homepage := Some(
url("https://github.com/neandertech/cue4s")
),
startYear := Some(2023),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
developers := List(
Developer(
"keynmol",
"Anton Sviridov",
"velbm@pm.me",
url("https://blog.indoorvivants.com")
)
),
version := (if (!sys.env.contains("CI")) "dev" else version.value)
)
)
val Versions = new {
val Scala3 = "3.3.3"
val munit = "1.0.0"
val scalaVersions = Seq(Scala3)
val fansi = "0.5.0"
val jna = "5.14.0"
val catsEffect = "3.5.3"
}
lazy val munitSettings = Seq(
libraryDependencies += {
"org.scalameta" %%% "munit" % Versions.munit % Test
}
)
lazy val root = project
.in(file("."))
.aggregate(core.projectRefs*)
.aggregate(catsEffect.projectRefs*)
.aggregate(example.projectRefs*)
.settings(noPublish)
lazy val core = projectMatrix
.in(file("modules/core"))
.defaultAxes(defaults*)
.settings(
name := "cue4s"
)
.settings(munitSettings)
.jvmPlatform(Versions.scalaVersions)
.jsPlatform(Versions.scalaVersions)
.nativePlatform(Versions.scalaVersions)
.settings(
snapshotsPackageName := "cue4s",
snapshotsIntegrations += SnapshotIntegration.MUnit,
scalacOptions += "-Wunused:all",
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
libraryDependencies += "com.lihaoyi" %%% "fansi" % Versions.fansi,
libraryDependencies +=
"net.java.dev.jna" % "jna" % Versions.jna,
nativeConfig ~= (_.withIncrementalCompilation(true))
)
.enablePlugins(SnapshotsPlugin)
.settings(superMatrix)
lazy val catsEffect = projectMatrix
.in(file("modules/cats-effect"))
.defaultAxes(defaults*)
.settings(
name := "cue4s-cats-effect"
)
.dependsOn(core)
.settings(munitSettings)
.jvmPlatform(Versions.scalaVersions)
.jsPlatform(Versions.scalaVersions)
.settings(
snapshotsPackageName := "cue4s.catseffect",
snapshotsIntegrations += SnapshotIntegration.MUnit,
scalacOptions += "-Wunused:all",
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
libraryDependencies += "org.typelevel" %%% "cats-effect" % Versions.catsEffect,
nativeConfig ~= (_.withIncrementalCompilation(true))
)
.enablePlugins(SnapshotsPlugin)
lazy val example = projectMatrix
.dependsOn(core)
.in(file("modules/example"))
.defaultAxes(defaults*)
.enablePlugins(JavaAppPackaging)
.settings(
name := "example",
noPublish
)
.settings(munitSettings)
.jvmPlatform(Versions.scalaVersions)
.jsPlatform(Versions.scalaVersions)
.nativePlatform(Versions.scalaVersions)
.settings(
scalacOptions += "-Wunused:all",
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
nativeConfig ~= (_.withIncrementalCompilation(true))
)
.settings(superMatrix)
lazy val superMatrix = Seq((Compile / unmanagedSourceDirectories) ++= {
val allCombos = List("js", "jvm", "native").combinations(2).toList
val dis =
virtualAxes.value.collectFirst { case p: VirtualAxis.PlatformAxis =>
p.directorySuffix
}.get
allCombos
.filter(_.contains(dis))
.map { suff =>
val suffixes = "scala" + suff.mkString("-", "-", "")
(Compile / sourceDirectory).value / suffixes
}
})
lazy val exampleCatsEffect = projectMatrix
.dependsOn(core, catsEffect)
.in(file("modules/example-catseffect"))
.defaultAxes(defaults*)
.enablePlugins(JavaAppPackaging)
.settings(
name := "example",
noPublish
)
.settings(munitSettings)
.jvmPlatform(Versions.scalaVersions)
.jsPlatform(Versions.scalaVersions)
.settings(
scalacOptions += "-Wunused:all",
scalaJSUseMainModuleInitializer := true,
Compile / mainClass := Some("example.catseffect.ioExample"),
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
nativeConfig ~= (_.withIncrementalCompilation(true))
)
lazy val docs =
project
.in(file("target/.docs-target"))
.enablePlugins(MdocPlugin)
.settings(scalaVersion := Versions.Scala3)
.dependsOn(core.jvm(true), catsEffect.jvm(true))
val noPublish = Seq(
publish / skip := true,
publishLocal / skip := true
)
val defaults =
Seq(VirtualAxis.scalaABIVersion(Versions.Scala3), VirtualAxis.jvm)
val scalafixRules = Seq(
"OrganizeImports",
"DisableSyntax",
"LeakingImplicitClassVal",
"NoValInForComprehension"
).mkString(" ")
val CICommands = Seq(
"clean",
"compile",
"test",
"checkDocs",
"scalafmtCheckAll",
"scalafmtSbtCheck",
s"scalafix --check $scalafixRules",
"headerCheck"
).mkString(";")
val PrepareCICommands = Seq(
s"scalafix --rules $scalafixRules",
"scalafmtAll",
"scalafmtSbt",
"headerCreate"
).mkString(";")
addCommandAlias("ci", CICommands)
addCommandAlias("preCI", PrepareCICommands)
addCommandAlias(
"testSnapshots",
"""set Test/envVars += ("SNAPSHOTS_INTERACTIVE" -> "true"); test"""
)
addCommandAlias("checkDocs", "docs/mdoc --in README.md")
Global / onChangedBuildSource := ReloadOnSourceChanges