-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
331 lines (306 loc) · 9.24 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
329
330
331
inThisBuild(
List(
scalaVersion := V.scala213,
crossScalaVersions := V.scalaAll,
organization := "com.yoohaemin",
homepage := Some(url("https://github.com/yoohaemin/decrel")),
licenses := List("MPL-2.0" -> url("https://www.mozilla.org/MPL/2.0/")),
Test / parallelExecution := true,
scmInfo := Some(
ScmInfo(
url("https://github.com/yoohaemin/decrel/"),
"scm:git:[email protected]:yoohaemin/decrel.git"
)
),
developers := List(
Developer(
"yoohaemin",
"Haemin Yoo",
url("https://github.com/yoohaemin")
)
),
ConsoleHelper.welcomeMessage,
versionScheme := Some("early-semver"),
organizationName := "Haemin Yoo",
startYear := Some(2022)
) ::: ciSettings
)
name := "decrel"
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias(
"fmtCheck",
"all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck"
)
//TODO uncomment native crossbuilds when ZIO published against native 0.4.8+ is out
//Related: https://github.com/scala-native/scala-native/issues/2858
lazy val root = project
.in(file("."))
.aggregate(
coreJVM,
coreJS,
// coreNative,
zqueryJVM,
zqueryJS,
fetchJVM,
fetchJS,
ziotestJVM,
ziotestJS,
// ziotestNative,
scalacheckJVM,
scalacheckJS,
// scalacheckNative,
catsJVM,
catsJS,
// catsNative,
docs
)
.settings(
crossScalaVersions := Nil
)
.enablePlugins(NoPublishPlugin)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(name := "decrel-core")
.settings(commonSettings)
.settings(
libraryDependencies ++=
Seq(
"dev.zio" %%% "izumi-reflect" % V.izumiReflect,
"dev.zio" %%% "zio-test" % V.zio % Test,
"dev.zio" %%% "zio-test-sbt" % V.zio % Test
)
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
///////////////////////// Haxl based datatypes
lazy val zquery = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("zquery"))
.enablePlugins(BuildInfoPlugin)
.settings(name := "decrel-zquery")
.settings(commonSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"scalaPartialVersion" -> CrossVersion.partialVersion(scalaVersion.value)
),
buildInfoPackage := "decrel.zquery",
buildInfoObject := "BuildInfo"
)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio-query" % V.zioQuery,
"dev.zio" %%% "zio-test" % V.zio % Test,
"dev.zio" %%% "zio-test-sbt" % V.zio % Test
)
)
.dependsOn(core)
lazy val zqueryJVM = zquery.jvm
lazy val zqueryJS = zquery.js
lazy val fetch = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file("fetch"))
.enablePlugins(BuildInfoPlugin)
.settings(name := "decrel-fetch")
.settings(commonSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"scalaPartialVersion" -> CrossVersion.partialVersion(scalaVersion.value)
),
buildInfoPackage := "decrel.fetch",
buildInfoObject := "BuildInfo"
)
.settings(
libraryDependencies ++= Seq(
"com.47deg" %%% "fetch" % V.fetch
)
)
.dependsOn(cats)
lazy val fetchJVM = fetch.jvm.settings(crossScalaVersions := V.scalaAll)
lazy val fetchJS = fetch.js.settings(crossScalaVersions := List(V.scala213))
///////////////////////// Generator datatypes
lazy val ziotest = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("ziotest"))
.enablePlugins(BuildInfoPlugin)
.settings(name := "decrel-ziotest")
.settings(commonSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"scalaPartialVersion" -> CrossVersion.partialVersion(scalaVersion.value)
),
buildInfoPackage := "decrel.ziotest",
buildInfoObject := "BuildInfo"
)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio-test" % V.zio,
"dev.zio" %%% "zio-test-sbt" % V.zio % Test
)
)
.dependsOn(core)
lazy val ziotestJVM = ziotest.jvm
lazy val ziotestJS = ziotest.js
lazy val scalacheck = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("scalacheck"))
.enablePlugins(BuildInfoPlugin)
.settings(name := "decrel-scalacheck")
.settings(commonSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"scalaPartialVersion" -> CrossVersion.partialVersion(scalaVersion.value)
),
buildInfoPackage := "decrel.scalacheck",
buildInfoObject := "BuildInfo"
)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % V.scalacheck
)
)
.dependsOn(core)
lazy val scalacheckJVM = scalacheck.jvm
lazy val scalacheckJS = scalacheck.js
///////////////////////// General purpose datatypes
lazy val cats = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("cats"))
.enablePlugins(BuildInfoPlugin)
.settings(name := "decrel-cats")
.settings(commonSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"scalaPartialVersion" -> CrossVersion.partialVersion(scalaVersion.value)
),
buildInfoPackage := "decrel.cats",
buildInfoObject := "BuildInfo"
)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % V.cats
)
)
.dependsOn(core)
lazy val catsJVM = cats.jvm
lazy val catsJS = cats.js
///////////////////////// docs
lazy val jsdocs = project
.settings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % V.scalajsDom,
crossScalaVersions := List(V.scala213)
)
.dependsOn(coreJS, zqueryJS, fetchJS, ziotestJS, scalacheckJS)
.enablePlugins(ScalaJSPlugin)
.enablePlugins(NoPublishPlugin)
lazy val docs = project
.in(file("mdoc"))
.enablePlugins(MdocPlugin)
.settings(commonSettings)
.settings(
name := "decrel-docs",
moduleName := name.value,
mdocIn := (ThisBuild / baseDirectory).value / "mdoc" / "docs",
mdocOut := (ThisBuild / baseDirectory).value / "vuepress" / "docs",
run / fork := false,
scalacOptions -= "-Xfatal-warnings",
mdocJS := Some(jsdocs),
crossScalaVersions := List(V.scala213),
mdocVariables := Map(
"SNAPSHOTVERSION" -> version.value,
"RELEASEVERSION" -> version.value.takeWhile(_ != '+')
)
)
.dependsOn(coreJVM, zqueryJVM, fetchJVM, ziotestJVM, scalacheckJVM)
.enablePlugins(NoPublishPlugin)
lazy val commonSettings = Def.settings(
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:higherKinds",
"-language:existentials",
"-unchecked",
"-Xfatal-warnings"
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) =>
Seq(
"-Xsource:3",
"-Xlint:-byname-implicit",
"-explaintypes",
"-Vimplicits",
"-Vtype-diffs",
"-P:kind-projector:underscore-placeholders"
)
case Some((3, _)) =>
Seq(
"-no-indent",
"-Ykind-projector"
)
case _ => Nil
}),
Test / fork := false,
run / fork := true,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.13"))
List(compilerPlugin("org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full))
else
Nil
}
)
lazy val V = new {
val scala213 = "2.13.15"
val scala3 = "3.3.4"
val scalaAll = scala213 :: scala3 :: Nil
val cats = "2.12.0"
val zio = "2.1.13"
val zioQuery = "0.7.6"
val fetch = "3.1.2"
val izumiReflect = "2.3.10"
val scalacheck = "1.18.1"
val scalajsDom = "2.3.0"
}
lazy val ciSettings = List(
githubWorkflowPublishTargetBranches := List(RefPredicate.Equals(Ref.Branch("master"))),
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11")),
githubWorkflowUseSbtThinClient := false,
githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("++${{ matrix.scala }} test"))),
githubWorkflowPublishTargetBranches += RefPredicate.StartsWith(Ref.Tag("v")),
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
),
githubWorkflowGeneratedUploadSteps := {
val skipCache = List("fetch/.js", "jsdocs", "mdoc")
githubWorkflowGeneratedUploadSteps.value match {
case (run: WorkflowStep.Run) :: t if run.commands.head.startsWith("tar cf") =>
assert(run.commands.length == 1)
run.copy(
commands = List(
skipCache.foldLeft(run.commands.head) { (acc, v) =>
acc.replace(s"$v/target", "")
}
)
) :: t
case l => l
}
},
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)