forked from Iltotore/iron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
481 lines (329 loc) · 11.3 KB
/
build.sc
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
import $ivy.`io.chris-kipp::mill-ci-release::0.1.9`
import io.kipp.mill.ci.release.CiReleaseModule
import de.tobiasroeser.mill.vcs.version.VcsVersion
import mill._, define._, api.Result
import scalalib._, scalalib.scalafmt._, scalalib.publish._, scalajslib._, scalanativelib._
object versions {
val scala = "3.3.1"
val scalaJS = "1.13.2"
val scalaNative = "0.4.15"
}
trait BaseModule extends ScalaModule with ScalafmtModule with CiReleaseModule { outer =>
def scalaVersion = versions.scala
def pomSettings =
PomSettings(
description = "Strong type constraints for Scala",
organization = "io.github.iltotore",
url = "https://github.com/Iltotore/iron",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("Iltotore", "iron"),
developers = Seq(
Developer("Iltotore", "Raphaël FROMENTIN", "https://github.com/Iltotore")
)
)
trait Tests extends ScalaTests with ScalafmtModule {
def testFramework = "utest.runner.Framework"
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1"
)
}
trait CrossModule extends ScalaModule with ScalafmtModule with CiReleaseModule {
def segment: String
def sources = T.sources(outer.sources() :+ PathRef(millSourcePath / s"src-$segment"))
def scalaVersion = outer.scalaVersion
def ivyDeps = outer.ivyDeps
def artifactName = outer.artifactName
def publishVersion = outer.publishVersion
def pomSettings = outer.pomSettings
}
trait JSCrossModule extends CrossModule with ScalaJSModule {
def segment = "js"
def scalaJSVersion = versions.scalaJS
}
trait NativeCrossModule extends CrossModule with ScalaNativeModule {
def segment = "native"
def scalaNativeVersion = versions.scalaNative
}
}
object docs extends BaseModule {
def scalaVersion = versions.scala
def artifactName = "iron-docs"
val modules: Seq[ScalaModule] =
Seq(main, cats, circe, decline, doobie, upickle, ciris, jsoniter, scalacheck, skunk, upickle, zio, zioJson)
def docSources = T.sources {
T.traverse(modules)(_.docSources)().flatten
}
def compileClasspath = T {
T.traverse(modules)(_.compileClasspath)().flatten
}
def gitTags = T {
os
.proc("git", "tag", "-l", "v*.*.*")
.call(VcsVersion.vcsBasePath)
.out
.trim()
.split("\n")
.reverse
}
def docVersions = T.source {
val targetDir = T.dest / "_assets"
val versions =
gitTags()
.filterNot(v => v.contains("-RC") || v.isBlank)
.map(_.substring(1))
def versionLink(version: String): String = {
val splat = version.split("\\.")
val (major, minor) = (splat(0).toInt, splat(1).toInt)
if(major >= 2 && minor >= 2) s"https://www.javadoc.io/doc/io.github.iltotore/iron-docs_3/$version/docs/index.html"
else s"https://www.javadoc.io/doc/io.github.iltotore/iron_3/$version/docs/index.html"
}
val links = versions.map(v => (v, ujson.Str(versionLink(v))))
val withNightly = links :+ ("Nightly", ujson.Str("https://iltotore.github.io/iron/docs/index.html"))
val json = ujson.Obj("versions" -> ujson.Obj.from(withNightly))
val versionsFile = targetDir / "versions.json"
os.write.over(versionsFile, ujson.write(json), createFolders = true)
T.dest
}
def docResources = T.sources(millSourcePath, docVersions().path)
def docRevision = T {
val version = main.publishVersion()
if(gitTags().contains(version)) version
else "main"
}
def externalMappings = Seq(
".*cats.*" -> ("scaladoc3", "https://javadoc.io/doc/org.typelevel/cats-docs_3/latest/"),
".*io.circe.*" -> ("scaladoc2", "https://circe.github.io/circe/api/"),
".*ciris.*" -> ("scaladoc2", "https://cir.is/api/"),
".*com.monovore.decline.*" -> ("scaladoc3", "https://javadoc.io/doc/com.monovore/decline_3/latest/"),
".*doobie.*" -> ("scaladoc3", "https://www.javadoc.io/doc/org.tpolecat/doobie-core_3/latest/"),
".*com.github.plokhotnyuk.jsoniter_scala.core.*" -> ("scaladoc3", "https://www.javadoc.io/doc/com.github.plokhotnyuk.jsoniter-scala/jsoniter-scala-core_3/latest/"),
".*io.bullet.borer.*" -> ("scaladoc3", "https://javadoc.io/doc/io.bullet/borer-core_3/latest/"),
".*org.scalacheck.*" -> ("scaladoc3", "https://javadoc.io/doc/org.scalacheck/scalacheck_3/latest/"),
".*skunk.*" -> ("scaladoc3", "https://javadoc.io/doc/org.tpolecat/skunk-docs_3/latest/"),
".*upickle.core.*" -> ("scaladoc3", "https://javadoc.io/doc/com.lihaoyi/upickle-core_3/latest/"),
".*upickle[^\\.core].*" -> ("scaladoc3", "https://javadoc.io/doc/com.lihaoyi/upickle_3/latest/"),
".*zio.json.*" -> ("scaladoc3", "https://javadoc.io/doc/dev.zio/zio-json_3/latest/"),
".*zio.prelude.*" -> ("scaladoc3", "https://javadoc.io/doc/dev.zio/zio-prelude-docs_3/latest/"),
".*zio[^\\.json].*" -> ("scaladoc3", "https://javadoc.io/doc/dev.zio/zio_3/latest/")
)
def scalaDocOptions = {
val externalMappingsFlag =
externalMappings
.map {
case (regex, (docType, link)) => s"$regex::$docType::$link"
}
.mkString(",")
Seq(
"-project", "Iron",
"-project-version", main.publishVersion(),
"-versions-dictionary-url", "https://iltotore.github.io/iron/versions.json",
"-source-links:github://Iltotore/iron",
"-revision", docRevision(),
"-snippet-compiler:nocompile",
s"-social-links:github::${main.pomSettings().url}",
s"-external-mappings:$externalMappingsFlag"
)
}
}
object main extends BaseModule {
def artifactName = "iron"
object test extends Tests
object js extends JSCrossModule
object native extends NativeCrossModule
}
object examples extends Module {
object catsValidation extends ScalaModule with ScalafmtModule {
def scalaVersion = versions.scala
def moduleDeps = Seq(main, cats)
def ivyDeps = Agg(
ivy"org.typelevel::cats-effect:3.3.14"
)
}
object formCats extends ScalaModule with ScalafmtModule {
def scalaVersion = versions.scala
def moduleDeps = Seq(main, cats, circe)
val circeVersion = "0.14.3"
val http4sVersion = "0.23.16"
def ivyDeps = Agg(
//ivy"org.typelevel::cats-core:2.8.0",
ivy"io.circe::circe-core:$circeVersion",
ivy"io.circe::circe-parser:$circeVersion",
ivy"io.circe::circe-generic:$circeVersion",
ivy"org.http4s::http4s-core:$http4sVersion",
ivy"org.http4s::http4s-dsl:$http4sVersion",
ivy"org.http4s::http4s-ember-server:$http4sVersion",
ivy"org.http4s::http4s-circe:$http4sVersion",
)
}
object formZio extends ScalaModule with ScalafmtModule {
def scalaVersion = versions.scala
def moduleDeps = Seq(main, zioJson)
def ivyDeps = Agg(
ivy"dev.zio::zio-test:2.0.4",
ivy"dev.zio::zio-json:0.3.0",
ivy"dev.zio::zio-http:0.0.3"
)
}
object formJsoniter extends ScalaModule with ScalafmtModule {
def scalaVersion = versions.scala
def moduleDeps = Seq(main, jsoniter)
val jsoniterVersion = "2.19.1"
def ivyDeps = Agg(
ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-core:$jsoniterVersion",
)
def compileIvyDeps = Agg(
ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:$jsoniterVersion"
)
}
object borerSerialization extends ScalaModule with ScalafmtModule {
def scalaVersion = versions.scala
def moduleDeps = Seq(main, borer)
def ivyDeps = Agg(
ivy"io.bullet::borer-core::1.13.0",
ivy"io.bullet::borer-derivation::1.13.0"
)
}
}
trait SubModule extends BaseModule {
def moduleDeps = Seq(main)
trait JSCrossModule extends super.JSCrossModule {
def moduleDeps = Seq(main.js)
}
trait NativeCrossModule extends super.NativeCrossModule {
def transitiveIvyDeps = T { super.transitiveIvyDeps().filter(d => !(d.dep.module.name.value == "scala3-library")) }
def moduleDeps = Seq(main.native)
}
}
object sandbox extends SubModule {
def artifactName = "sandbox"
}
object cats extends SubModule {
def artifactName = "iron-cats"
def ivyDeps = Agg(
ivy"org.typelevel::cats-core::2.8.0"
)
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1",
ivy"org.typelevel::kittens:3.0.0"
)
}
object js extends JSCrossModule
object native extends NativeCrossModule
}
object upickle extends SubModule {
def artifactName = "iron-upickle"
def ivyDeps = Agg(
ivy"com.lihaoyi::upickle:3.1.3"
)
object test extends Tests {
}
object js extends JSCrossModule
object native extends NativeCrossModule
}
object circe extends SubModule {
def artifactName = "iron-circe"
def ivyDeps = Agg(
ivy"io.circe::circe-core::0.14.3"
)
object js extends JSCrossModule
object native extends NativeCrossModule
}
object ciris extends SubModule {
def artifactName = "iron-ciris"
def ivyDeps = Agg(
ivy"is.cir::ciris::3.1.0"
)
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1",
ivy"is.cir::ciris::3.1.0"
)
}
object js extends JSCrossModule
object native extends NativeCrossModule
}
object zio extends SubModule {
def artifactName = "iron-zio"
def ivyDeps = Agg(
ivy"dev.zio::zio::2.0.5",
ivy"dev.zio::zio-prelude::1.0.0-RC16"
)
object js extends JSCrossModule
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1"
)
}
}
object zioJson extends SubModule {
def artifactName = "iron-zio-json"
def ivyDeps = Agg(
ivy"dev.zio::zio-json::0.3.0"
)
object js extends JSCrossModule
}
object jsoniter extends SubModule {
def artifactName = "iron-jsoniter"
val jsoniterVersion = "2.19.1"
private val jsoniterMacros = ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:$jsoniterVersion"
def ivyDeps = Agg(
ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-core::$jsoniterVersion"
)
def compileIvyDeps = Agg(jsoniterMacros)
object js extends JSCrossModule {
def compileIvyDeps = Agg(jsoniterMacros)
}
object native extends NativeCrossModule {
def compileIvyDeps = Agg(jsoniterMacros)
}
object test extends Tests {
def compileIvyDeps = Agg(jsoniterMacros)
}
}
object borer extends SubModule {
def artifactName = "iron-borer"
def ivyDeps = Agg(
ivy"io.bullet::borer-core::1.13.0"
)
object js extends JSCrossModule
object test extends Tests
}
object skunk extends SubModule {
def artifactName = "iron-skunk"
def ivyDeps = Agg(
ivy"org.tpolecat::skunk-core::0.6.1"
)
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1",
ivy"org.tpolecat::skunk-core::0.6.1"
)
}
object js extends JSCrossModule
object native extends NativeCrossModule
}
object scalacheck extends SubModule {
def artifactName = "iron-scalacheck"
def ivyDeps = Agg(
ivy"org.scalacheck::scalacheck::1.17.0"
)
object js extends JSCrossModule
object test extends Tests
}
object doobie extends SubModule {
def artifactName = "iron-doobie"
def ivyDeps = Agg(
ivy"org.tpolecat::doobie-core::1.0.0-RC5"
)
object test extends Tests
}
object decline extends SubModule {
def artifactName = "iron-decline"
def ivyDeps = Agg(
ivy"com.monovore::decline::2.4.1"
)
object test extends Tests
object js extends JSCrossModule
object native extends NativeCrossModule
}