-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sbt
245 lines (228 loc) · 6.2 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
import com.github.sbt.git.SbtGit.GitKeys
val scala212 = "2.12.20"
val scala213 = "2.13.15"
val scala3 = "3.4.3"
val updateReadme = inputKey[Unit]("Update readme")
addCommandAlias("ci", "; lint; +test; readme/updateReadme; +publishLocal")
addCommandAlias(
"lint",
"; scalafmtSbtCheck; scalafmtCheckAll; Compile/scalafix --check; Test/scalafix --check"
)
addCommandAlias("fix", "; Compile/scalafix; Test/scalafix; scalafmtSbt; scalafmtAll")
val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := scala213,
scalacOptions ++=
Seq(
"-feature",
"-deprecation",
"-unchecked",
"-encoding",
"UTF-8",
"-language:higherKinds"
) ++
(if (scalaBinaryVersion.value.startsWith("2.12"))
List(
"-Xfatal-warnings", // fail when there are warnings
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-unused",
"-Ypartial-unification",
"-Ywarn-value-discard"
)
else if (scalaBinaryVersion.value.startsWith("2.13"))
List("-Werror", "-Wdead-code", "-Wunused", "-Wvalue-discard")
else if (scalaBinaryVersion.value.startsWith("3"))
List(
"-explain",
"-explain-types",
"-indent",
"-print-lines",
"-Ykind-projector",
"-Xmigration",
"-Xfatal-warnings"
)
else
Nil),
crossScalaVersions := Seq(scala212, scala213, scala3),
Test / console / scalacOptions := Seq(),
Compile / console / scalacOptions := Seq(),
licenses := Seq("MIT" -> url("http://spdx.org/licenses/MIT")),
homepage := Some(url("https://github.com/eikek/calev")),
versionScheme := Some("early-semver")
) ++ publishSettings
lazy val publishSettings = Seq(
scmInfo := Some(
ScmInfo(
url("https://github.com/eikek/calev.git"),
"scm:git:[email protected]:eikek/calev.git"
)
),
developers := List(
Developer(
id = "eikek",
name = "Eike Kettner",
url = url("https://github.com/eikek"),
email = ""
)
),
Test / publishArtifact := false
)
lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
val testSettings = Seq(
libraryDependencies ++= (Dependencies.munit ++ Dependencies.logback).map(_ % Test),
testFrameworks += TestFrameworks.MUnit
)
val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
GitKeys.gitHeadCommit,
GitKeys.gitHeadCommitDate,
GitKeys.gitUncommittedChanges,
GitKeys.gitDescribedVersion
),
buildInfoOptions += BuildInfoOption.ToJson,
buildInfoOptions += BuildInfoOption.BuildTime
)
val scalafixSettings = Seq(
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version
)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file("modules/core"))
.settings(sharedSettings)
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-core",
libraryDependencies ++=
Dependencies.fs2.map(_ % Test) ++
Dependencies.fs2io.map(_ % Test)
)
lazy val fs2 = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file("modules/fs2"))
.settings(sharedSettings)
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-fs2",
libraryDependencies ++=
Dependencies.fs2
)
.dependsOn(core)
lazy val doobie = project
.in(file("modules/doobie"))
.settings(sharedSettings)
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-doobie",
libraryDependencies ++=
Dependencies.doobie ++
Dependencies.h2.map(_ % Test)
)
.dependsOn(core.jvm)
lazy val circe = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file("modules/circe"))
.settings(sharedSettings)
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-circe",
libraryDependencies ++=
Dependencies.circe ++
Dependencies.circeAll.map(_ % Test)
)
.dependsOn(core)
lazy val jackson = project
.in(file("modules/jackson"))
.dependsOn(core.jvm)
.settings(sharedSettings)
.settings(testSettings)
.settings(scalafixSettings)
.settings(
name := "calev-jackson",
crossScalaVersions := Seq(scala212, scala213),
developers += Developer(
id = "pawelkaczor",
name = "Paweł Kaczor",
url = url("https://github.com/pawelkaczor"),
email = ""
),
libraryDependencies ++=
Dependencies.jacksonAll
)
lazy val akka = project
.in(file("modules/akka"))
.dependsOn(core.jvm)
.settings(sharedSettings)
.settings(scalafixSettings)
.settings(
name := "calev-akka",
crossScalaVersions := Seq(scala212, scala213),
developers += Developer(
id = "pawelkaczor",
name = "Paweł Kaczor",
url = url("https://github.com/pawelkaczor"),
email = ""
),
libraryDependencies ++=
Dependencies.akkaAll ++ Dependencies.scalaTest ++ Dependencies.logback.map(_ % Test)
)
lazy val readme = project
.in(file("modules/readme"))
.enablePlugins(MdocPlugin)
.settings(sharedSettings)
.settings(noPublish)
.settings(
name := "calev-readme",
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++=
Dependencies.circeAll,
scalacOptions -= "-Xfatal-warnings",
scalacOptions -= "-Werror",
mdocVariables := Map(
"VERSION" -> latestRelease.value
),
mdocIn := (LocalRootProject / baseDirectory).value / "docs" / "readme.md",
mdocOut := (LocalRootProject / baseDirectory).value / "README.md",
fork := true,
updateReadme := {
mdoc.evaluated
()
}
)
.dependsOn(core.jvm, fs2.jvm, doobie, circe.jvm, jackson, akka)
val root = project
.in(file("."))
.settings(sharedSettings)
.settings(noPublish)
.settings(
name := "calev-root",
crossScalaVersions := Nil
)
.aggregate(
core.jvm,
core.js,
fs2.jvm,
fs2.js,
doobie,
circe.jvm,
circe.js,
jackson,
akka
)