forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
1891 lines (1667 loc) · 65.2 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
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// plugins and dependencies
import $file.ci.shared
import $file.ci.upload
import $ivy.`org.scalaj::scalaj-http:2.4.2`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.1.0`
import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.29`
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:`
import $ivy.`com.goyeau::mill-scalafix::0.3.2`
// imports
import com.github.lolgab.mill.mima.{CheckDirection, ProblemFilter, Mima}
import coursier.maven.MavenRepository
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.goyeau.mill.scalafix.ScalafixModule
import mill._
import mill.api.JarManifest
import mill.define.NamedTask
import mill.main.Tasks
import mill.scalalib._
import mill.scalalib.api.ZincWorkerUtil
import mill.scalalib.publish._
import mill.util.Jvm
import mill.resolve.SelectMode
import mill.contrib.buildinfo.BuildInfo
import mill.scalalib.api.Versions
import mill.T
import mill.define.Cross
object Settings {
val pomOrg = "com.lihaoyi"
val githubOrg = "com-lihaoyi"
val githubRepo = "mill"
val projectUrl = s"https://github.com/${githubOrg}/${githubRepo}"
val changelogUrl = s"${projectUrl}#changelog"
val newIssueUrl = s"${projectUrl}/issues/new/choose"
val docUrl = "https://mill-build.com"
// the exact branches containing a doc root
val docBranches = Seq()
// the exact tags containing a doc root
val legacyDocTags: Seq[String] = Seq(
"0.9.12",
"0.10.0",
"0.10.12",
"0.10.15",
"0.11.0-M7"
)
val docTags: Seq[String] = Seq()
val mimaBaseVersions: Seq[String] = 0.to(6).map("0.11." + _)
}
object Deps {
// The Scala version to use
val scalaVersion = "2.13.12"
// Scoverage 1.x will not get releases for newer Scala versions
val scalaVersionForScoverageWorker1 = "2.13.8"
// The Scala 2.12.x version to use for some workers
val workerScalaVersion212 = "2.12.18"
val testScala213Version = "2.13.8"
val testScala212Version = "2.12.6"
val testScala211Version = "2.11.12"
val testScala210Version = "2.10.6"
val testScala30Version = "3.0.2"
val testScala31Version = "3.1.3"
val testScala32Version = "3.2.0"
val testScala33Version = "3.3.1"
object Scalajs_1 {
val scalaJsVersion = "1.15.0"
val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0"
val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0"
val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0"
val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0"
val scalajsEnvSelenium = ivy"org.scala-js::scalajs-env-selenium:1.1.1"
val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:${scalaJsVersion}"
val scalajsLinker = ivy"org.scala-js::scalajs-linker:${scalaJsVersion}"
}
object Scalanative_0_4 {
val scalanativeVersion = "0.4.16"
val scalanativeTools = ivy"org.scala-native::tools:${scalanativeVersion}"
val scalanativeUtil = ivy"org.scala-native::util:${scalanativeVersion}"
val scalanativeNir = ivy"org.scala-native::nir:${scalanativeVersion}"
val scalanativeTestRunner = ivy"org.scala-native::test-runner:${scalanativeVersion}"
}
trait Play {
def playVersion: String
def playBinVersion: String = playVersion.split("[.]").take(2).mkString(".")
def routesCompiler = playBinVersion match {
case "2.6" | "2.7" | "2.8" => ivy"com.typesafe.play::routes-compiler::$playVersion"
case "2.9" => ivy"com.typesafe.play::play-routes-compiler::$playVersion"
case _ => ivy"org.playframework::play-routes-compiler::$playVersion"
}
def scalaVersion: String = Deps.scalaVersion
}
object Play_2_6 extends Play {
def playVersion = "2.6.25"
override def scalaVersion: String = Deps.workerScalaVersion212
}
object Play_2_7 extends Play {
val playVersion = "2.7.9"
}
object Play_2_8 extends Play {
val playVersion = "2.8.21"
}
object Play_2_9 extends Play {
val playVersion = "2.9.1"
}
object Play_3_0 extends Play {
val playVersion = "3.0.1"
}
val play =
Seq(Play_3_0, Play_2_9, Play_2_8, Play_2_7, Play_2_6).map(p => (p.playBinVersion, p)).toMap
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.9"
val ammoniteVersion = "3.0.0-M0-53-084f7f4e"
val asmTree = ivy"org.ow2.asm:asm-tree:9.6"
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"
val coursier = ivy"io.get-coursier::coursier:2.1.8"
val coursierInterface = ivy"io.get-coursier:interface:1.0.19"
val cask = ivy"com.lihaoyi::cask:0.9.1"
val castor = ivy"com.lihaoyi::castor:0.3.0"
val fastparse = ivy"com.lihaoyi::fastparse:3.0.2"
val flywayCore = ivy"org.flywaydb:flyway-core:8.5.13"
val graphvizJava = ivy"guru.nidi:graphviz-java-all-j2v8:0.18.1"
val junixsocket = ivy"com.kohlschutter.junixsocket:junixsocket-core:2.8.3"
val jgraphtCore = ivy"org.jgrapht:jgrapht-core:1.4.0" // 1.5.0+ dont support JDK8
val jline = ivy"org.jline:jline:3.25.0"
val jnaVersion = "5.14.0"
val jna = ivy"net.java.dev.jna:jna:${jnaVersion}"
val jnaPlatform = ivy"net.java.dev.jna:jna-platform:${jnaVersion}"
val junitInterface = ivy"com.github.sbt:junit-interface:0.13.3"
val lambdaTest = ivy"de.tototec:de.tobiasroeser.lambdatest:0.8.0"
val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.22.1"
val osLib = ivy"com.lihaoyi::os-lib:0.9.3"
val pprint = ivy"com.lihaoyi::pprint:0.8.1"
val mainargs = ivy"com.lihaoyi::mainargs:0.6.1"
val millModuledefsVersion = "0.10.9"
val millModuledefsString = s"com.lihaoyi::mill-moduledefs:${millModuledefsVersion}"
val millModuledefs = ivy"${millModuledefsString}"
val millModuledefsPlugin =
ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${millModuledefsVersion}"
// can't use newer versions, as these need higher Java versions
val testng = ivy"org.testng:testng:7.5.1"
val sbtTestInterface = ivy"org.scala-sbt:test-interface:1.0"
val scalaCheck = ivy"org.scalacheck::scalacheck:1.17.0"
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}"
// last scalafmt release supporting Java 8 is 3.7.15
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.7.15" // scala-steward:off
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}"
val scalacScoveragePlugin = ivy"org.scoverage:::scalac-scoverage-plugin:1.4.11"
val scoverage2Version = "2.0.11"
val scalacScoverage2Plugin = ivy"org.scoverage:::scalac-scoverage-plugin:${scoverage2Version}"
val scalacScoverage2Reporter = ivy"org.scoverage::scalac-scoverage-reporter:${scoverage2Version}"
val scalacScoverage2Domain = ivy"org.scoverage::scalac-scoverage-domain:${scoverage2Version}"
val scalacScoverage2Serializer =
ivy"org.scoverage::scalac-scoverage-serializer:${scoverage2Version}"
val scalaparse = ivy"com.lihaoyi::scalaparse:${fastparse.version}"
val scalatags = ivy"com.lihaoyi::scalatags:0.12.0"
// keep in sync with doc/antora/antory.yml
val semanticDBscala = ivy"org.scalameta:::semanticdb-scalac:4.8.15"
val semanticDbJava = ivy"com.sourcegraph:semanticdb-java:0.9.8"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.1"
val upickle = ivy"com.lihaoyi::upickle:3.1.4"
val utest = ivy"com.lihaoyi::utest:0.8.2"
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.5"
val zinc = ivy"org.scala-sbt::zinc:1.9.6"
// keep in sync with doc/antora/antory.yml
val bsp4j = ivy"ch.epfl.scala:bsp4j:2.2.0-M1"
val fansi = ivy"com.lihaoyi::fansi:0.4.0"
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.9.0"
val requests = ivy"com.lihaoyi::requests:0.8.0"
/** Used to manage transitive versions. */
val transitiveDeps = Seq(
ivy"org.apache.ant:ant:1.10.14",
ivy"commons-io:commons-io:2.15.1",
ivy"com.google.code.gson:gson:2.10.1",
ivy"com.google.protobuf:protobuf-java:3.25.1",
ivy"com.google.guava:guava:32.1.3-jre",
ivy"org.yaml:snakeyaml:2.2"
)
/** Used in tests. */
object TestDeps {
// tests framework (test)
val scalaTest = ivy"org.scalatest::scalatest:3.2.17"
val zioTest = ivy"dev.zio::zio-test:2.0.21"
}
/** Used in documentation. */
object DocDeps {
val millScip = ivy"io.chris-kipp::mill-scip_mill0.11:0.3.7"
}
}
def millVersion: T[String] = T { VcsVersion.vcsState().format() }
def millLastTag: T[String] = T {
VcsVersion.vcsState().lastTag.getOrElse(
sys.error("No (last) git tag found. Your git history seems incomplete!")
)
}
def millBinPlatform: T[String] = T {
val tag = millLastTag()
if (tag.contains("-M")) tag
else {
val pos = if (tag.startsWith("0.")) 2 else 1
tag.split("[.]", pos + 1).take(pos).mkString(".")
}
}
def baseDir = build.millSourcePath
val bridgeScalaVersions = Seq(
// Our version of Zinc doesn't work with Scala 2.12.0 and 2.12.4 compiler
// bridges. We skip 2.12.1 because it's so old not to matter, and we need a
// non-supported scala versionm for testing purposes. We skip 2.13.0-2 because
// scaladoc fails on windows
/*"2.12.0",*/ /*2.12.1",*/ "2.12.2",
"2.12.3", /*"2.12.4",*/ "2.12.5",
"2.12.6",
"2.12.7",
"2.12.8",
"2.12.9",
"2.12.10",
"2.12.11",
"2.12.12",
"2.12.13",
"2.12.14",
"2.12.15",
"2.12.16",
"2.12.17",
"2.12.18",
/*"2.13.0", "2.13.1", "2.13.2",*/ "2.13.3",
"2.13.4",
"2.13.5",
"2.13.6",
"2.13.7",
"2.13.8",
"2.13.9",
"2.13.10",
"2.13.11",
"2.13.12"
)
// We limit the number of compiler bridges to compile and publish for local
// development and testing, because otherwise it takes forever to compile all
// of them. Compiler bridges not in this set will get downloaded and compiled
// on the fly anyway. For publishing, we publish everything or a specific version
// if given.
val compilerBridgeScalaVersions =
interp.watchValue(sys.env.get("MILL_COMPILER_BRIDGE_VERSIONS")) match {
case None => Seq.empty[String]
case Some("all") => bridgeScalaVersions
case Some(versions) => versions.split(',').map(_.trim).toSeq
}
val bridgeVersion = "0.0.1"
trait MillJavaModule extends JavaModule {
// Test setup
def testDep = T { (s"com.lihaoyi-${artifactId()}", testDepPaths().map(_.path).mkString("\n")) }
// Workaround for Zinc/JNA bug
// https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130
def testArgs: T[Seq[String]] = T { Seq("-Djna.nosys=true") }
def testDepPaths = T { upstreamAssemblyClasspath() ++ Seq(compile().classes) ++ resources() }
def testTransitiveDeps: T[Map[String, String]] = T {
val upstream = T.traverse(moduleDeps ++ compileModuleDeps) {
case m: MillJavaModule => m.testTransitiveDeps.map(Some(_))
case _ => T.task(None)
}().flatten.flatten
val current = Seq(testDep())
upstream.toMap ++ current
}
def repositoriesTask = T.task {
super.repositoriesTask() ++
Seq(MavenRepository("https://oss.sonatype.org/content/repositories/releases"))
}
def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = T.task {
super.mapDependencies().andThen { dep =>
forcedVersions.find(f =>
f.dep.module.organization.value == dep.module.organization.value &&
f.dep.module.name.value == dep.module.name.value
).map { forced =>
val newDep = dep.withVersion(forced.dep.version)
T.log.debug(s"Forcing version of ${dep.module} from ${dep.version} to ${newDep.version}")
newDep
}.getOrElse(dep)
}
}
val forcedVersions: Seq[Dep] = Deps.transitiveDeps ++ Seq(
Deps.jline,
Deps.jna
)
}
trait MillPublishJavaModule extends MillJavaModule with PublishModule {
def commonPomSettings(artifactName: String) = {
PomSettings(
description = artifactName,
organization = Settings.pomOrg,
url = Settings.projectUrl,
licenses = Seq(License.MIT),
versionControl = VersionControl.github(Settings.githubOrg, Settings.githubRepo),
developers = Seq(
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi"),
Developer("lefou", "Tobias Roeser", "https://github.com/lefou")
)
)
}
def artifactName = "mill-" + super.artifactName()
def publishVersion = millVersion()
def publishProperties = super.publishProperties() ++ Map(
"info.releaseNotesURL" -> Settings.changelogUrl
)
def pomSettings = commonPomSettings(artifactName())
def javacOptions = Seq("-source", "1.8", "-target", "1.8", "-encoding", "UTF-8")
}
/**
* Some custom scala settings and test convenience
*/
trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModule { outer =>
def scalaVersion = Deps.scalaVersion
def scalafixScalaBinaryVersion = ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
def scalacOptions =
super.scalacOptions() ++ Seq(
"-deprecation",
"-P:acyclic:force",
"-feature",
"-Xlint:unused",
"-Xlint:adapted-args"
)
def testIvyDeps: T[Agg[Dep]] = Agg(Deps.utest)
def testModuleDeps: Seq[JavaModule] =
if (this == main) Seq(main)
else Seq(this, main.test)
def writeLocalTestOverrides = T.task {
for ((k, v) <- testTransitiveDeps()) {
os.write(T.dest / "mill" / "local-test-overrides" / k, v, createFolders = true)
}
Seq(PathRef(T.dest))
}
def runClasspath = super.runClasspath() ++ writeLocalTestOverrides()
def scalacPluginIvyDeps =
super.scalacPluginIvyDeps() ++
Agg(Deps.acyclic) ++
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefsPlugin)
def mandatoryIvyDeps =
super.mandatoryIvyDeps() ++
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefs)
/** Default tests module. */
lazy val test: MillScalaTests = new MillScalaTests {}
trait MillScalaTests extends ScalaTests with MillBaseTestsModule {
def runClasspath = super.runClasspath() ++ writeLocalTestOverrides()
def forkArgs = super.forkArgs() ++ outer.testArgs()
def moduleDeps = outer.testModuleDeps
def ivyDeps = super.ivyDeps() ++ outer.testIvyDeps()
}
}
trait MillBaseTestsModule extends MillJavaModule with TestModule {
def forkArgs = T {
Seq(
s"-DMILL_SCALA_2_13_VERSION=${Deps.scalaVersion}",
s"-DMILL_SCALA_2_12_VERSION=${Deps.workerScalaVersion212}",
s"-DTEST_SCALA_2_13_VERSION=${Deps.testScala213Version}",
s"-DTEST_SCALA_2_12_VERSION=${Deps.testScala212Version}",
s"-DTEST_SCALA_2_11_VERSION=${Deps.testScala211Version}",
s"-DTEST_SCALA_2_10_VERSION=${Deps.testScala210Version}",
s"-DTEST_SCALA_3_0_VERSION=${Deps.testScala30Version}",
s"-DTEST_SCALA_3_1_VERSION=${Deps.testScala31Version}",
s"-DTEST_SCALA_3_2_VERSION=${Deps.testScala32Version}",
s"-DTEST_SCALA_3_3_VERSION=${Deps.testScala33Version}",
s"-DTEST_SCALAJS_VERSION=${Deps.Scalajs_1.scalaJsVersion}",
s"-DTEST_SCALANATIVE_VERSION=${Deps.Scalanative_0_4.scalanativeVersion}",
s"-DTEST_UTEST_VERSION=${Deps.utest.dep.version}",
s"-DTEST_SCALATEST_VERSION=${Deps.TestDeps.scalaTest.dep.version}",
s"-DTEST_TEST_INTERFACE_VERSION=${Deps.sbtTestInterface.dep.version}",
s"-DTEST_ZIOTEST_VERSION=${Deps.TestDeps.zioTest.dep.version}",
s"-DTEST_ZINC_VERSION=${Deps.zinc.dep.version}"
)
}
def testFramework = "mill.UTestFramework"
}
/** Published module which does not contain strictly handled API. */
trait MillPublishScalaModule extends MillScalaModule with MillPublishJavaModule
/** Publishable module which contains strictly handled API. */
trait MillStableScalaModule extends MillPublishScalaModule with Mima {
import com.github.lolgab.mill.mima._
override def mimaBinaryIssueFilters: T[Seq[ProblemFilter]] = Seq(
// MIMA doesn't properly ignore things which are nested inside other private things
// so we have to put explicit ignores here (https://github.com/lightbend/mima/issues/771)
ProblemFilter.exclude[Problem]("mill.eval.ProfileLogger*"),
ProblemFilter.exclude[Problem]("mill.eval.GroupEvaluator*"),
ProblemFilter.exclude[Problem]("mill.eval.Tarjans*"),
ProblemFilter.exclude[Problem]("mill.define.Ctx#Impl*"),
ProblemFilter.exclude[Problem]("mill.resolve.ResolveNotFoundHandler*"),
// See https://github.com/com-lihaoyi/mill/pull/2739
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalajslib.ScalaJSModule.mill$scalajslib$ScalaJSModule$$super$scalaLibraryIvyDeps"
)
)
def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions
def mimaPreviousArtifacts: T[Agg[Dep]] = T {
Agg.from(
Settings.mimaBaseVersions
.filter(v => !skipPreviousVersions().contains(v))
.map(version =>
ivy"${pomSettings().organization}:${artifactId()}:${version}"
)
)
}
def mimaExcludeAnnotations = Seq("mill.api.internal", "mill.api.experimental")
def mimaCheckDirection = CheckDirection.Backward
def skipPreviousVersions: T[Seq[String]] = T(Seq.empty[String])
}
object bridge extends Cross[BridgeModule](compilerBridgeScalaVersions)
trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
def scalaVersion = crossScalaVersion
def publishVersion = bridgeVersion
def artifactName = "mill-scala-compiler-bridge"
def pomSettings = commonPomSettings(artifactName())
def crossFullScalaVersion = true
def ivyDeps = Agg(
ivy"org.scala-sbt:compiler-interface:${Versions.zinc}",
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
def resources = T.sources {
os.copy(generatedSources().head.path / "META-INF", T.dest / "META-INF")
Seq(PathRef(T.dest))
}
def generatedSources = T {
import mill.scalalib.api.ZincWorkerUtil.{grepJar, scalaBinaryVersion}
val resolvedJars = resolveDeps(
T.task {
Agg(ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.dep.version}").map(bindDependency())
},
sources = true
)()
val bridgeJar = grepJar(
resolvedJars,
s"compiler-bridge_${scalaBinaryVersion(scalaVersion())}",
Deps.zinc.dep.version,
true
)
mill.api.IO.unpackZip(bridgeJar.path, os.rel)
Seq(PathRef(T.dest))
}
}
object main extends MillStableScalaModule with BuildInfo {
def moduleDeps = Seq(eval, resolve, client)
def ivyDeps = Agg(
Deps.windowsAnsi,
Deps.mainargs,
Deps.coursierInterface,
Deps.requests
)
def compileIvyDeps = Agg(Deps.scalaReflect(scalaVersion()))
def buildInfoPackageName = "mill.main"
def buildInfoMembers = Seq(
BuildInfo.Value("scalaVersion", scalaVersion(), "Scala version used to compile mill core."),
BuildInfo.Value(
"workerScalaVersion212",
Deps.workerScalaVersion212,
"Scala 2.12 version used by some workers."
),
BuildInfo.Value("millVersion", millVersion(), "Mill version."),
BuildInfo.Value("millBinPlatform", millBinPlatform(), "Mill binary platform version."),
BuildInfo.Value(
"millEmbeddedDeps",
T.traverse(dev.moduleDeps)(_.publishSelfDependency)()
.map(artifact => s"${artifact.group}:${artifact.id}:${artifact.version}")
.mkString(","),
"Dependency artifacts embedded in mill assembly by default."
),
BuildInfo.Value(
"millScalacPluginDeps",
Deps.millModuledefsString,
"Scalac compiler plugin dependencies to compile the build script."
)
)
object api extends MillStableScalaModule with BuildInfo {
def buildInfoPackageName = "mill.api"
def buildInfoMembers = Seq(
BuildInfo.Value("millVersion", millVersion(), "Mill version."),
BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url."),
BuildInfo.Value(
"millReportNewIssueUrl",
Settings.newIssueUrl,
"URL to create a new issue in Mills issue tracker."
)
)
def ivyDeps = Agg(
Deps.osLib,
Deps.upickle,
Deps.pprint,
Deps.fansi,
Deps.sbtTestInterface
)
}
object util extends MillStableScalaModule {
def moduleDeps = Seq(api, client)
def ivyDeps = Agg(Deps.coursier, Deps.jline)
}
object codesig extends MillPublishScalaModule {
override def ivyDeps =
Agg(Deps.asmTree, Deps.osLib, Deps.pprint)
def moduleDeps = Seq(util)
override lazy val test: CodeSigTests = new CodeSigTests {}
trait CodeSigTests extends MillScalaTests {
val caseKeys = interp.watchValue(
os.walk(millSourcePath / "cases", maxDepth = 3)
.map(_.subRelativeTo(millSourcePath / "cases").segments)
.collect { case Seq(a, b, c) => s"$a-$b-$c" }
)
def testLogFolder = T { T.dest }
def caseEnvs[V](f1: CaseModule => Task[V])(s: String, f2: V => String) = {
T.traverse(caseKeys) { i => f1(cases(i)).map(v => s"MILL_TEST_${s}_$i" -> f2(v)) }
}
def forkEnv = T {
Map("MILL_TEST_LOGS" -> testLogFolder().toString) ++
caseEnvs(_.compile)("CLASSES", _.classes.path.toString)() ++
caseEnvs(_.compileClasspath)("CLASSPATH", _.map(_.path).mkString(","))() ++
caseEnvs(_.sources)("SOURCES", _.head.path.toString)()
}
object cases extends Cross[CaseModule](caseKeys)
trait CaseModule extends ScalaModule with Cross.Module[String] {
def caseName = crossValue
object external extends ScalaModule {
def scalaVersion = Deps.scalaVersion
}
def moduleDeps = Seq(external)
val Array(prefix, suffix, rest) = caseName.split("-", 3)
def millSourcePath = super.millSourcePath / prefix / suffix / rest
def scalaVersion = Deps.scalaVersion
def ivyDeps = T {
if (!caseName.contains("realistic") && !caseName.contains("sourcecode")) super.ivyDeps()
else Agg(
Deps.fastparse,
Deps.scalatags,
Deps.cask,
Deps.castor,
Deps.mainargs,
Deps.requests,
Deps.osLib,
Deps.upickle
)
}
}
}
}
object define extends MillStableScalaModule {
def moduleDeps = Seq(api, util)
def compileIvyDeps = Agg(Deps.scalaReflect(scalaVersion()))
def ivyDeps = Agg(
Deps.millModuledefs,
// Necessary so we can share the JNA classes throughout the build process
Deps.jna,
Deps.jnaPlatform,
Deps.jarjarabrams,
Deps.mainargs,
Deps.scalaparse
)
}
object eval extends MillStableScalaModule {
def moduleDeps = Seq(define)
}
object resolve extends MillStableScalaModule {
def moduleDeps = Seq(define)
}
object client extends MillPublishJavaModule with BuildInfo {
def buildInfoPackageName = "mill.main.client"
def buildInfoMembers = Seq(BuildInfo.Value("millVersion", millVersion(), "Mill version."))
def ivyDeps = Agg(Deps.junixsocket)
object test extends JavaModuleTests with TestModule.Junit4 {
def ivyDeps = Agg(Deps.junitInterface, Deps.lambdaTest)
}
}
object graphviz extends MillPublishScalaModule {
def moduleDeps = Seq(main, scalalib)
def ivyDeps = Agg(Deps.graphvizJava, Deps.jgraphtCore)
}
object testkit extends MillPublishScalaModule {
def moduleDeps = Seq(eval, util, main)
}
def testModuleDeps = super.testModuleDeps ++ Seq(testkit)
}
object testrunner extends MillPublishScalaModule {
def moduleDeps = Seq(scalalib.api, main.util, entrypoint)
object entrypoint extends MillPublishJavaModule {
override def ivyDeps = Agg(Deps.sbtTestInterface)
}
}
def formatDep(dep: Dep) = {
val d = Lib.depToDependency(dep, Deps.scalaVersion)
s"${d.module.organization.value}:${d.module.name.value}:${d.version}"
}
object scalalib extends MillStableScalaModule {
def moduleDeps = Seq(main, scalalib.api, testrunner)
def ivyDeps = Agg(Deps.scalafmtDynamic)
def testIvyDeps = super.testIvyDeps() ++ Agg(Deps.scalaCheck)
def testTransitiveDeps = super.testTransitiveDeps() ++ Seq(worker.testDep())
object backgroundwrapper extends MillPublishJavaModule with MillJavaModule {
def ivyDeps = Agg(Deps.sbtTestInterface)
}
object api extends MillStableScalaModule with BuildInfo {
def moduleDeps = Seq(main.api)
def buildInfoPackageName = "mill.scalalib.api"
def buildInfoObjectName = "Versions"
def buildInfoMembers = Seq(
BuildInfo.Value("ammonite", Deps.ammoniteVersion, "Version of Ammonite."),
BuildInfo.Value("zinc", Deps.zinc.dep.version, "Version of Zinc"),
BuildInfo.Value("scalafmtVersion", Deps.scalafmtDynamic.dep.version, "Version of Scalafmt"),
BuildInfo.Value("semanticDBVersion", Deps.semanticDBscala.dep.version, "SemanticDB version."),
BuildInfo.Value(
"semanticDbJavaVersion",
Deps.semanticDbJava.dep.version,
"Java SemanticDB plugin version."
),
BuildInfo.Value(
"millModuledefsVersion",
Deps.millModuledefsVersion,
"Mill ModuleDefs plugins version."
),
BuildInfo.Value("millCompilerBridgeScalaVersions", bridgeScalaVersions.mkString(",")),
BuildInfo.Value("millCompilerBridgeVersion", bridgeVersion),
BuildInfo.Value("millVersion", millVersion(), "Mill version.")
)
}
object worker extends MillPublishScalaModule with BuildInfo {
def moduleDeps = Seq(scalalib.api)
def ivyDeps = Agg(Deps.zinc, Deps.log4j2Core)
def buildInfoPackageName = "mill.scalalib.worker"
def buildInfoObjectName = "Versions"
def buildInfoMembers = Seq(
BuildInfo.Value("zinc", Deps.zinc.dep.version, "Version of Zinc.")
)
}
}
object scalajslib extends MillStableScalaModule with BuildInfo {
def moduleDeps = Seq(scalalib, scalajslib.`worker-api`)
def testTransitiveDeps = super.testTransitiveDeps() ++ Seq(worker("1").testDep())
def buildInfoPackageName = "mill.scalajslib"
def buildInfoObjectName = "ScalaJSBuildInfo"
def buildInfoMembers = T {
val resolve = resolveCoursierDependency()
def formatDep(dep: Dep) = {
val d = resolve(dep)
s"${d.module.organization.value}:${d.module.name.value}:${d.version}"
}
Seq(
BuildInfo.Value("scalajsEnvNodejs", formatDep(Deps.Scalajs_1.scalajsEnvNodejs)),
BuildInfo.Value("scalajsEnvJsdomNodejs", formatDep(Deps.Scalajs_1.scalajsEnvJsdomNodejs)),
BuildInfo.Value(
"scalajsEnvExoegoJsdomNodejs",
formatDep(Deps.Scalajs_1.scalajsEnvExoegoJsdomNodejs)
),
BuildInfo.Value("scalajsEnvPhantomJs", formatDep(Deps.Scalajs_1.scalajsEnvPhantomjs)),
BuildInfo.Value("scalajsEnvSelenium", formatDep(Deps.Scalajs_1.scalajsEnvSelenium))
)
}
object `worker-api` extends MillPublishScalaModule {
def ivyDeps = Agg(Deps.sbtTestInterface)
}
object worker extends Cross[WorkerModule]("1")
trait WorkerModule extends MillPublishScalaModule with Cross.Module[String] {
def scalajsWorkerVersion = crossValue
def millSourcePath: os.Path = super.millSourcePath / scalajsWorkerVersion
def testDepPaths = T { Seq(compile().classes) }
def moduleDeps = Seq(scalajslib.`worker-api`, main.client, main.api)
def ivyDeps = Agg(
Deps.Scalajs_1.scalajsLinker,
Deps.Scalajs_1.scalajsSbtTestAdapter,
Deps.Scalajs_1.scalajsEnvNodejs,
Deps.Scalajs_1.scalajsEnvJsdomNodejs,
Deps.Scalajs_1.scalajsEnvExoegoJsdomNodejs,
Deps.Scalajs_1.scalajsEnvPhantomjs,
Deps.Scalajs_1.scalajsEnvSelenium
)
}
}
object contrib extends Module {
def contribModules: Seq[ContribModule] =
millInternal.modules.collect { case m: ContribModule => m }
trait ContribModule extends MillPublishScalaModule {
def readme = T.source(millSourcePath / "readme.adoc")
}
object testng extends JavaModule with ContribModule {
def testTransitiveDeps =
super.testTransitiveDeps() ++
Seq(scalalib.testDep(), scalalib.worker.testDep(), testrunner.entrypoint.testDep())
// pure Java implementation
def artifactSuffix: T[String] = ""
def scalaLibraryIvyDeps: T[Agg[Dep]] = T { Agg.empty[Dep] }
def ivyDeps = Agg(Deps.sbtTestInterface)
def compileIvyDeps = Agg(Deps.testng)
def runIvyDeps = Agg(Deps.testng)
def testModuleDeps: Seq[JavaModule] = super.testModuleDeps ++ Seq(scalalib)
def docJar: T[PathRef] = super[JavaModule].docJar
}
object twirllib extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps: Seq[JavaModule] = super.testModuleDeps ++ Seq(scalalib)
}
object playlib extends ContribModule {
def moduleDeps = Seq(twirllib, playlib.api)
def compileModuleDeps = Seq(scalalib)
def testTransitiveDeps =
super.testTransitiveDeps() ++ T.traverse(Deps.play.keys.toSeq)(worker(_).testDep)()
def testArgs = T {
super.testArgs() ++
Seq(
s"-DTEST_PLAY_VERSION_2_6=${Deps.Play_2_6.playVersion}",
s"-DTEST_PLAY_VERSION_2_7=${Deps.Play_2_7.playVersion}",
s"-DTEST_PLAY_VERSION_2_8=${Deps.Play_2_8.playVersion}",
s"-DTEST_PLAY_VERSION_2_9=${Deps.Play_2_9.playVersion}",
s"-DTEST_PLAY_VERSION_3_0=${Deps.Play_3_0.playVersion}"
)
}
def testModuleDeps: Seq[JavaModule] = super.testModuleDeps ++ Seq(scalalib)
object api extends MillPublishJavaModule
object worker extends Cross[WorkerModule](Deps.play.keys.toSeq)
trait WorkerModule extends MillPublishScalaModule with Cross.Module[String] {
def playBinary = crossValue
def millSourcePath: os.Path = super.millSourcePath / playBinary
def sources = T.sources {
// We want to avoid duplicating code as long as the Play APIs allow.
// But if newer Play versions introduce incompatibilities,
// just remove the shared source dir for that worker and implement directly.
Seq(PathRef(millSourcePath / os.up / "src-shared")) ++ super.sources()
}
def scalaVersion = Deps.play(playBinary).scalaVersion
def moduleDeps = Seq(playlib.api)
def ivyDeps = Agg(Deps.osLib, Deps.play(playBinary).routesCompiler)
}
}
object scalapblib extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
object scoverage extends ContribModule {
object api extends MillPublishScalaModule {
def compileModuleDeps = Seq(main.api)
}
def moduleDeps = Seq(scoverage.api)
def compileModuleDeps = Seq(scalalib)
def testTransitiveDeps =
super.testTransitiveDeps() ++ Seq(worker.testDep(), worker2.testDep())
def testArgs = T {
super.testArgs() ++
Seq(
s"-DMILL_SCOVERAGE_VERSION=${Deps.scalacScoveragePlugin.dep.version}",
s"-DMILL_SCOVERAGE2_VERSION=${Deps.scalacScoverage2Plugin.dep.version}",
s"-DTEST_SCALA_2_12_VERSION=2.12.15" // last supported 2.12 version for Scoverage 1.x
)
}
// So we can test with buildinfo in the classpath
def testModuleDeps =
super.testModuleDeps ++
Seq(scalalib, scalajslib, scalanativelib, contrib.buildinfo)
// Worker for Scoverage 1.x
object worker extends MillPublishScalaModule {
// scoverage is on an old Scala version which doesnt support scalafix
def fix(args: String*): Command[Unit] = T.command {}
def compileModuleDeps = Seq(main.api)
def moduleDeps = Seq(scoverage.api)
def testDepPaths = T { Seq(compile().classes) }
// compile-time only, need to provide the correct scoverage version at runtime
def compileIvyDeps = Agg(Deps.scalacScoveragePlugin)
def scalaVersion = Deps.scalaVersionForScoverageWorker1
}
// Worker for Scoverage 2.0
object worker2 extends MillPublishScalaModule {
def compileModuleDeps = Seq(main.api)
def moduleDeps = Seq(scoverage.api)
def testDepPaths = T { Seq(compile().classes) }
def compileIvyDeps = T {
Agg(
// compile-time only, need to provide the correct scoverage version at runtime
Deps.scalacScoverage2Plugin,
Deps.scalacScoverage2Reporter,
Deps.scalacScoverage2Domain,
Deps.scalacScoverage2Serializer
)
}
}
}
object buildinfo extends ContribModule {
def compileModuleDeps = Seq(scalalib, scalajslib, scalanativelib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib, scalajslib, scalanativelib)
}
object proguard extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
object flyway extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def ivyDeps = Agg(Deps.flywayCore)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
object docker extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
object bloop extends ContribModule with BuildInfo {
def compileModuleDeps = Seq(scalalib, scalajslib, scalanativelib)
def ivyDeps = Agg(Deps.bloopConfig.exclude("*" -> s"jsoniter-scala-core_2.13"))
def testModuleDeps = super.testModuleDeps ++ Seq(
scalalib,
scalajslib,
scalanativelib
)
def buildInfoPackageName = "mill.contrib.bloop"
def buildInfoObjectName = "Versions"
def buildInfoMembers = Seq(BuildInfo.Value("bloop", Deps.bloopConfig.dep.version))
}
object artifactory extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def ivyDeps = Agg(Deps.requests)
}
object codeartifact extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def ivyDeps = Agg(Deps.requests)
}
object versionfile extends ContribModule {
def compileModuleDeps = Seq(scalalib)
}
object bintray extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def ivyDeps = Agg(Deps.requests)
}
object gitlab extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def ivyDeps = Agg(Deps.requests, Deps.osLib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
object jmh extends ContribModule {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(scalalib)
}
}
object scalanativelib extends MillStableScalaModule {
def moduleDeps = Seq(scalalib, scalanativelib.`worker-api`)
def testTransitiveDeps = super.testTransitiveDeps() ++ Seq(worker("0.4").testDep())
object `worker-api` extends MillPublishScalaModule {
def ivyDeps = Agg(Deps.sbtTestInterface)
}
object worker extends Cross[WorkerModule]("0.4")
trait WorkerModule extends MillPublishScalaModule with Cross.Module[String] {
def scalaNativeWorkerVersion = crossValue
def millSourcePath: os.Path = super.millSourcePath / scalaNativeWorkerVersion
def testDepPaths = T { Seq(compile().classes) }
def moduleDeps = Seq(scalanativelib.`worker-api`)
def ivyDeps = scalaNativeWorkerVersion match {
case "0.4" =>
Agg(
Deps.osLib,
Deps.Scalanative_0_4.scalanativeTools,
Deps.Scalanative_0_4.scalanativeUtil,
Deps.Scalanative_0_4.scalanativeNir,
Deps.Scalanative_0_4.scalanativeTestRunner
)
}
}
}
object bsp extends MillPublishScalaModule with BuildInfo {
def compileModuleDeps = Seq(scalalib)
def testModuleDeps = super.testModuleDeps ++ compileModuleDeps
def buildInfoPackageName = "mill.bsp"
def buildInfoMembers = T {
val workerDep = worker.publishSelfDependency()
Seq(
BuildInfo.Value(
"bsp4jVersion",
Deps.bsp4j.dep.version,
"BSP4j version (BSP Protocol version)."
)
)
}
override lazy val test: MillScalaTests = new Test {}
trait Test extends MillScalaTests {
def forkEnv: T[Map[String, String]] = T {
// We try to fetch this dependency with coursier in the tests
bsp.worker.publishLocalCached()
super.forkEnv()
}
def forkArgs = super.forkArgs() ++ Seq(s"-DBSP4J_VERSION=${Deps.bsp4j.dep.version}")