generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathbuild.mill
More file actions
547 lines (463 loc) · 18.9 KB
/
build.mill
File metadata and controls
547 lines (463 loc) · 18.9 KB
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
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
//| mvnDeps:
//| - com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION
//| - com.lihaoyi::mill-contrib-scoverage:$MILL_VERSION
//| - com.carlosedp::mill-aliases::1.1.0
//| - com.github.lolgab::mill-mima::0.2.0
package build
import millbuild.{Deps, MillVersions, Versions => Vers, ScalaVersions => ScalaVers}
import millbuild.config.PlatformConfig
import millbuild.docs.{Docusaurus2Module, MDocModule}
import mill.scalalib.publish.PublishInfo
import mill.local.plugins.ci.release.ReleaseSetupModule
import com.carlosedp.aliases.*
import millbuild.*
import millbuild.crossplatform.*
import millbuild.jsruntime.*
import org.finos.millmorphir.*
import org.finos.millmorphir.elm.*
import mill.*, mill.scalalib.*, mill.scalajslib.*, mill.scalanativelib.*, scalafmt.*
import mill.javalib.SonatypeCentralPublishModule
import mill.scalajslib.api.ModuleKind
import mill.contrib.buildinfo.BuildInfo
import mill.contrib.scoverage.{ScoverageModule, ScoverageReport}
import com.github.lolgab.mill.mima.*
import mill.util.VcsVersion
import scala.concurrent.duration.DurationInt
/**
* The version of Scala natively supported by the toolchain. Morphir itself may provide backends that generate code for
* other Scala versions.
*/
val morphirScalaVersion: String = ScalaVers.scala3
val docsScalaVersion: String = ScalaVers.scala213
// Get workspace dir from the build context
val workspaceDir = mill.api.BuildCtx.workspaceRoot
def showBuildSettings() = Task.Command {
println(s"morphirScalaVersion: ${morphirScalaVersion}")
println(s"docsScalaVersion: ${docsScalaVersion}")
println(s"scalaJSVersion: ${ScalaVers.scalaJSVersion}")
println(s"scalaNativeVersion: ${ScalaVers.scalaNativeVersion}")
println(s"Platform JVM enabled: ${PlatformConfig.enableJVM}")
println(s"Platform JS enabled: ${PlatformConfig.enableJS}")
println(s"Platform Native enabled: ${PlatformConfig.enableNative}")
()
}
object scoverage extends ScoverageReport {
// While the plugin doesn't seem to support multiple scala versions, that doesn't seem to impact the coverage
// For overall coverage report, just specifying Scala 3
def scalaVersion = ScalaVers.scala3x
def scoverageVersion = Vers.scoverage
}
trait MorphirPublishModule extends PublishModule with JavaModule with Mima with SonatypeCentralPublishModule {
import mill.scalalib.publish.*
def publishVersion = VcsVersion.vcsState().format()
def packageDescription: String = s"The $artifactName package"
def pomSettings = PomSettings(
description = packageDescription,
organization = "org.finos.morphir",
url = "https://github.com/finos/morphir-scala",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("finos", "morphir-scala"),
developers = Seq(
Developer("DamianReeves", "Damian Reeves", "https://github.com/damianreeves")
)
)
}
object morphir extends CrossPlatform { morphir =>
object build extends Module {
object integration extends Module {
object `mill-morphir-elm` extends Cross[morphirlibElmPlugin](MillVersions.all)
trait morphirlibElmPlugin
extends Cross.Module[String]
with ScalaModule
with ScalafmtModule
with MorphirPublishModule {
def millVersion = crossValue
val pluginName = "mill-morphir-elm"
def scalaVersion = Task { ScalaVers.millScalaVersion }
override def artifactName = s"${pluginName}_mill${MillVersions.millBinaryVersion(millVersion)}"
override def compileMvnDeps = super.compileMvnDeps() ++ Seq(
mvn"com.lihaoyi::mill-scalalib:${millVersion}"
)
override def scalacOptions = Seq("-Ywarn-unused", "-deprecation")
override def sources = Task {
super.sources() ++ Seq(
PathRef(moduleDir / s"src-mill${millVersion.split('.').take(2).mkString(".")}")
)
}
}
}
}
object main extends CommonScalaModule with MorphirPublishModule with BuildInfo {
def buildInfoPackageName = "org.finos.morphir.cli"
def buildInfoMembers = Seq(
BuildInfo.Value("version", publishVersion()),
BuildInfo.Value("scalaVersion", scalaVersion())
)
override def extraPublish: T[Seq[PublishInfo]] = Task {
Seq(PublishInfo(file = assembly(), classifier = Some("assembly"), ivyConfig = "compile"))
}
val mainScalaVersion = morphirScalaVersion
def packageDescription =
"The morphir-main package. This is the main entry point for the morphir tooling, including the morphir-cli."
def scalaVersion = Task { mainScalaVersion }
def mvnDeps = Seq(
Deps.co.fs2.`fs2-io`,
Deps.com.lihaoyi.fansi,
Deps.com.lihaoyi.pprint,
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.zio,
Deps.dev.zio.`zio-interop-cats`,
Deps.dev.zio.`zio-cli`,
Deps.dev.zio.`zio-config`,
Deps.dev.zio.config.magnolia,
Deps.dev.zio.config.refined,
Deps.dev.zio.config.typesafe
)
def moduleDeps =
Seq(
jvm,
runtime.jvm,
tools.jvm
)
}
trait MorphirCommonModule extends ScalaModule with CommonScalaModule {
def semanticDbVersion: T[String] = Task { Vers.semanticDb(Some((3, 7))) }
def compilerPluginDependencies(selectedScalaVersion: String) =
Seq(Deps.org.`scala-lang`.`scala3-compiler`(selectedScalaVersion))
}
trait DeduplicatedSources extends ScalaModule {
override def sources: T[Seq[PathRef]] = Task {
super.sources().distinctBy(_.path)
}
}
trait MorphirCommonCrossModule extends CrossPlatformScalaModule with ScalafmtModule with DeduplicatedSources {
def scalaVersion = Task { morphirScalaVersion }
def semanticDbVersion: T[String] = Task { Vers.semanticDb(Some((3, 7))) }
def compilerPluginDependencies(selectedScalaVersion: String) =
Seq(Deps.org.`scala-lang`.`scala3-compiler`(selectedScalaVersion))
}
trait MorphirJVMModule extends MorphirCommonCrossModule {
def platform = Platform.JVM
}
trait MorphirJSModule extends MorphirCommonCrossModule with ScalaJSModule {
import mill.scalajslib.api.*
def platform = Platform.JS
def scalaJSVersion = Task { ScalaVers.scalaJSVersion }
}
trait MorphirNativeModule extends MorphirCommonCrossModule {
def platform = Platform.Native
def scalaNativeVersion = Task { ScalaVers.scalaNativeVersion }
}
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = super.mvnDeps() ++ Seq(
Deps.org.`scala-lang`.modules.`scala-collection-contrib`,
Deps.com.beachape.enumeratum,
Deps.com.lihaoyi.fansi,
Deps.com.lihaoyi.geny,
Deps.com.lihaoyi.sourcecode,
Deps.com.lihaoyi.pprint,
Deps.dev.zio.`izumi-reflect`,
Deps.dev.zio.zio,
Deps.dev.zio.`zio-json`,
Deps.dev.zio.`zio-prelude`,
Deps.org.typelevel.spire,
Deps.com.softwaremill.magnolia_3.magnolia
)
def platformSpecificModuleDeps = Seq(extensibility)
}
object jvm extends Shared with MorphirJVMModule
object js extends Shared with MorphirJSModule
object contrib extends Module {
object knowledge extends CrossPlatform {
def enableNative(module: Module): Boolean = false // Native disabled for Scala 3
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = Seq(
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.`zio-streams`
)
def platformSpecificModuleDeps = Seq(morphir)
}
object jvm extends Shared with MorphirJVMModule with ScoverageModule {
def scoverageVersion = Vers.scoverage
object test extends ScoverageTests with TestModule.ZioTest {
def mvnDeps = Seq(
Deps.dev.zio.zio,
Deps.dev.zio.`zio-streams`,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
def moduleDeps = super.moduleDeps ++ Seq(testing.zio.jvm)
}
}
object js extends Shared with MorphirJSModule {
object test extends ScalaJSTests with TestModule.ZioTest {
def mvnDeps = Seq(
Deps.dev.zio.zio,
Deps.dev.zio.`zio-streams`,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
def moduleDeps = super.moduleDeps ++ Seq(testing.zio.js)
}
}
}
}
object extensibility extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule with BuildInfo {
def buildInfoPackageName = "org.finos.morphir.extensibility"
def buildInfoMembers = Seq(
BuildInfo.Value("version", publishVersion()),
BuildInfo.Value("scalaVersion", scalaVersion()),
BuildInfo.Value("platform", platform.toString)
)
}
object jvm extends Shared with MorphirJVMModule
object js extends Shared with MorphirJSModule
}
object interop extends Module {
object zio extends Module {
object json extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = Seq(Deps.dev.zio.`zio-json`)
def platformSpecificModuleDeps = Seq(morphir)
}
object jvm extends Shared with MorphirJVMModule with ScoverageModule {
def scoverageVersion = Vers.scoverage
object test extends ScoverageTests with TestModule.ZioTest {
def mvnDeps: T[Seq[Dep]] = Task {
Seq(
Deps.dev.zio.`zio-json-golden`,
mvn"io.github.deblockt:json-diff:1.1.0",
mvn"com.fasterxml.jackson.core:jackson-databind:2.18.3",
Deps.dev.zio.`zio-process`
)
}
def moduleDeps = super.moduleDeps ++ Seq(morphir.testing.generators.jvm, testing.zio.jvm)
}
}
object js extends Shared with MorphirJSModule
}
}
object borer extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = Seq(
Deps.io.bullet.`borer-core`(morphirScalaVersion),
Deps.io.bullet.`borer-derivation`(morphirScalaVersion)
)
def platformSpecificModuleDeps = Seq(morphir)
}
object jvm extends Shared with MorphirJVMModule with ScoverageModule {
def scoverageVersion = Vers.scoverage
object test extends ScoverageTests with TestModule.ZioTest {
def mvnDeps: T[Seq[Dep]] = Task {
Seq(
Deps.io.bullet.`borer-core`(morphirScalaVersion),
Deps.io.bullet.`borer-derivation`(morphirScalaVersion)
)
}
def moduleDeps = super.moduleDeps ++ Seq(morphir.testing.generators.jvm, testing.zio.jvm)
}
}
object js extends Shared with MorphirJSModule
}
}
object lib extends Module {
object interop extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {}
object jvm extends Shared with MorphirJVMModule
object js extends Shared with MorphirJSModule
}
}
object runtime extends CrossPlatform {
def enableNative(module: Module): Boolean = false // Native disabled for Scala 3
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def platformSpecificModuleDeps = Seq(morphir, morphir.interop.zio.json)
}
trait RuntimeTests extends TestModule.ZioTest {
def morphirTestSources = Task {
examples.`morphir-elm-projects`.`evaluator-tests`.distOutputDirs()
}
def morphirTestSourceFiles = Task {
Lib.findSourceFiles(morphirTestSources(), Seq("json")).collect {
case path if path.last.startsWith("morphir-") => PathRef(path)
}
}
}
object jvm extends Shared with MorphirJVMModule with ScoverageModule {
def scoverageVersion = Vers.scoverage
object test extends ScoverageTests with RuntimeTests {
def mvnDeps = Seq(
Deps.com.lihaoyi.`os-lib`,
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
def moduleDeps = super.moduleDeps ++ Seq(testing.zio.jvm)
}
}
object js extends Shared with MorphirJSModule {
object test extends ScalaJSTests with RuntimeTests {
def mvnDeps = Seq(Deps.dev.zio.`zio-test`, Deps.dev.zio.`zio-test-sbt`)
def moduleDeps = super.moduleDeps ++ Seq(testing.zio.js)
def moduleKind = ModuleKind.CommonJSModule
}
}
}
object testing extends Module {
object generators extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule {
def mvnDeps = Seq(Deps.dev.zio.`zio-test`) ++ (if (!platform.isNative) Seq(Deps.dev.zio.`zio-test-magnolia`) else Seq.empty[Dep])
def platformSpecificModuleDeps = Seq(morphir)
}
object jvm extends Shared with MorphirJVMModule
object js extends Shared with MorphirJSModule
}
object zio extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule {
def mvnDeps = Seq(
mvn"io.github.cquiroz::scala-java-time::2.6.0",
Deps.dev.zio.`zio-json`,
Deps.dev.zio.`zio-prelude`,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
}
object jvm extends Shared with MorphirJVMModule
object js extends Shared with MorphirJSModule
}
}
object tests extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = super.mvnDeps() ++ Seq(
Deps.com.lihaoyi.sourcecode,
Deps.io.github.cquiroz.`scala-java-time`,
Deps.io.github.cquiroz.`scala-java-time-tzdb`
)
def platformSpecificModuleDeps = Seq(extensibility, morphir, runtime, tools)
}
object jvm extends Shared with MorphirJVMModule with ScoverageModule {
def scoverageVersion = Vers.scoverage
object test extends ScoverageTests with TestModule.ZioTest {
// Use cross-platform sources for test modules too
def crossPlatformTestSourcePaths: Seq[os.Path] = {
val basePath = moduleDir
val platformSuffixes = Seq("jvm", "jvm-native", "js-jvm")
val versionSuffixes = Seq("", "-3.7.4", "-3.7", "-3")
// Base sources
val baseSources = versionSuffixes.map(v => basePath / s"src$v")
// Platform-specific sources using nesting
val platformSources = platformSuffixes.flatMap { p =>
versionSuffixes.map(v => basePath / p / s"src$v")
}
(baseSources ++ platformSources).distinct
}
override def sources: T[Seq[PathRef]] = Task.Sources(crossPlatformTestSourcePaths*)
def mvnDeps = Seq(
Deps.com.lihaoyi.`os-lib`,
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
def moduleDeps = super.moduleDeps ++ Seq(testing.generators.jvm, testing.zio.jvm)
}
}
object js extends Shared with MorphirJSModule {
object test extends ScalaJSTests with TestModule.ZioTest {
// Use cross-platform sources for JS test modules too
def crossPlatformTestSourcePaths: Seq[os.Path] = {
val basePath = moduleDir
// JS platform: include js-specific and js-jvm shared sources (NOT jvm-native)
val platformSuffixes = Seq("js", "js-jvm")
val versionSuffixes = Seq("", "-3.7.4", "-3.7", "-3")
// Base sources
val baseSources = versionSuffixes.map(v => basePath / s"src$v")
// Platform-specific sources using nesting
val platformSources = platformSuffixes.flatMap { p =>
versionSuffixes.map(v => basePath / p / s"src$v")
}
(baseSources ++ platformSources).distinct
}
override def sources: T[Seq[PathRef]] = Task.Sources(crossPlatformTestSourcePaths*)
def mvnDeps = Seq(Deps.dev.zio.`zio-test`, Deps.dev.zio.`zio-test-sbt`)
def moduleDeps = super.moduleDeps ++ Seq(testing.generators.js, testing.zio.js)
}
}
}
object tools extends CrossPlatform {
trait Shared extends MorphirCommonCrossModule with MorphirPublishModule {
def mvnDeps = Seq(
Deps.co.fs2.`fs2-io`,
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.zio,
Deps.dev.zio.`zio-prelude`,
Deps.dev.zio.`zio-streams`,
Deps.com.lihaoyi.pprint,
Deps.org.typelevel.cats.core,
Deps.org.typelevel.spire,
Deps.org.typelevel.`paiges-core`
) ++ (if (!platform.isNative) Seq(Deps.dev.zio.`zio-interop-cats`) else Seq.empty[Dep])
def platformSpecificModuleDeps = Seq(morphir, morphir.interop.zio.json)
}
object jvm extends Shared with MorphirJVMModule {
def mvnDeps = super.mvnDeps() ++ Seq(
Deps.dev.zio.`zio-nio`,
Deps.dev.zio.`zio-process`
)
}
object js extends Shared with MorphirJSModule {
def docSources = Task {
Lib.findSourceFiles(super.docSources(), Seq("tasty"))
.map(PathRef(_))
// .filterNot(_.path.last.contains("ProcessIOPlat"))
}
}
}
}
// The following modules are morphir-elm modules that have been setup to be built using mill
// Morphir Elm Projects/Modules:
object examples extends Module {
object `morphir-elm-projects` extends Module {
object finance extends MorphirElmModule
object `evaluator-tests` extends MorphirElmModule
object `unit-test-framework` extends Module {
object `example-project` extends MorphirElmModule {
def morphirModuleDeps = Seq(`morphir-elm`.sdks.`morphir-unit-test`)
}
object `example-project-tests` extends MorphirElmModule {
def morphirModuleDeps = Seq(
`morphir-elm`.sdks.`morphir-unit-test`,
`example-project`
)
}
object `example-project-tests-incomplete` extends MorphirElmModule {
def morphirModuleDeps = Seq(
`morphir-elm`.sdks.`morphir-unit-test`,
`example-project`
)
}
object `example-project-tests-passing` extends MorphirElmModule {
def morphirModuleDeps = Seq(
`morphir-elm`.sdks.`morphir-unit-test`,
`example-project`
)
}
}
}
}
object `morphir-elm` extends Module {
object sdks extends Module {
object `morphir-unit-test` extends MorphirElmModule
}
}
// ci module removed - using Mill's built-in mill.scalalib.PublishModule/ for publishing
// The following section contains aliases used to simplify build tasks
object MyAliases extends Aliases {
def fmt = alias("mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources")
def checkfmt = alias("mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources")
def deps = alias("mill.scalalib.Dependency/showUpdates")
def testall = alias("__.test")
def testJVM = alias("morphir.__.jvm.__.test")
def testJVMCached = alias("morphir.__.jvm.__.testCached")
def compileall = alias("__.compile")
def comptestall = alias("__.compile", "__.test")
}