forked from coursier/coursier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sc
877 lines (806 loc) · 24.7 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
import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $file.project.deps, deps.{Deps, ScalaVersions}
import $file.project.docs
import $file.project.ghreleaseassets
import $file.project.launchers, launchers.{Launchers, platformBootstrapExtension}
import $file.project.modules.`bootstrap-launcher0`, `bootstrap-launcher0`.BootstrapLauncher
import $file.project.modules.cache0, cache0.{Cache, CacheJvmBase}
import $file.project.modules.core0, core0.{Core, CoreJvmBase}
import $file.project.modules.coursier0, coursier0.{Coursier, CoursierJvmBase, CoursierTests}
import $file.project.modules.directories0, directories0.Directories
import $file.project.modules.doc0, doc0.Doc
import $file.project.modules.interop0, interop0.{Cats, Scalaz}
import $file.project.modules.launcher0, launcher0.LauncherBase
import $file.project.modules.shared, shared.{
buildVersion,
CoursierPublishModule,
CsCrossJvmJsModule,
CsMima,
CsModule,
CsScalaJsModule,
CsTests,
JsTests,
JvmTests
}
import $file.project.modules.tests0, tests0.TestsModule
import $file.project.modules.util0, util0.{Util, UtilJvmBase}
import $file.project.publishing, publishing.mavenOrg
import $file.project.relativize, relativize.{relativize => doRelativize}
import $file.project.sync
import $file.project.workers
import mill._
import mill.scalalib._
import mill.scalajslib._
import mill.contrib.bloop.Bloop
import scala.concurrent.duration._
import scala.util.Properties
// Tell mill modules are under modules/
implicit def millModuleBasePath: define.BasePath =
define.BasePath(super.millModuleBasePath.value / "modules")
object util extends Module {
object jvm extends Cross[UtilJvm](ScalaVersions.all: _*)
object js extends Cross[UtilJs](ScalaVersions.all: _*)
}
object core extends Module {
object jvm extends Cross[CoreJvm](ScalaVersions.all: _*)
object js extends Cross[CoreJs](ScalaVersions.all: _*)
}
object cache extends Module {
object jvm extends Cross[CacheJvm](ScalaVersions.all: _*)
object js extends Cross[CacheJs](ScalaVersions.all: _*)
}
object launcher extends Cross[Launcher](ScalaVersions.all ++ Seq(ScalaVersions.scala211): _*)
object publish extends Cross[Publish](ScalaVersions.all: _*)
object env extends Cross[Env](ScalaVersions.all: _*)
object `launcher-native_03` extends LauncherNative03
object `launcher-native_040M2` extends LauncherNative040M2
object `launcher-native_04` extends LauncherNative04
object coursier extends Module {
object jvm extends Cross[CoursierJvm](ScalaVersions.all: _*)
object js extends Cross[CoursierJs](ScalaVersions.all: _*)
}
object directories extends Directories
object paths extends JavaModule {
def moduleDeps = Seq(
directories
)
def ivyDeps = Agg(
Deps.jniUtils
)
}
object `windows-ansi` extends Module {
object ps extends JavaModule
}
object `custom-protocol-for-test` extends SbtModule {
def scalaVersion = ScalaVersions.scala213
}
object `bootstrap-launcher` extends BootstrapLauncher { self =>
def sources = T.sources {
super.sources() ++
directories.sources() ++
paths.sources() ++
`windows-ansi`.ps.sources()
}
def resources = T.sources {
super.resources() ++ directories.resources()
}
def proguardClassPath = T {
proguard.runClasspath()
}
object test extends Tests with CsTests {
def ivyDeps = super.ivyDeps() ++ Seq(
Deps.collectionCompat,
Deps.java8Compat
)
}
object it extends Tests with CsTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
)
def moduleDeps = Seq(
self.test
)
def forkArgs = T.input {
val testRepoServer0 = workers.testRepoServer()
super.forkArgs() ++ Seq(
s"-Dtest.repository=${testRepoServer0.url}",
s"-Dtest.repository.user=${testRepoServer0.user}",
s"-Dtest.repository.password=${testRepoServer0.password}"
)
}
}
}
object proguard extends JavaModule {
def ivyDeps = Agg(
Deps.proguard
)
}
object tests extends Module {
object jvm extends Cross[TestsJvm](ScalaVersions.all: _*)
object js extends Cross[TestsJs](ScalaVersions.all: _*)
}
object `proxy-tests` extends Cross[ProxyTests](ScalaVersions.all: _*)
object interop extends Module {
object scalaz extends Module {
object jvm extends Cross[ScalazJvm](ScalaVersions.all: _*)
object js extends Cross[ScalazJs](ScalaVersions.all: _*)
}
object cats extends Module {
object jvm extends Cross[CatsJvm](ScalaVersions.all: _*)
object js extends Cross[CatsJs](ScalaVersions.all: _*)
}
}
object jvm extends Cross[Jvm](ScalaVersions.all: _*)
object install extends Cross[Install](ScalaVersions.all: _*)
object cli extends Cli
object `cli-tests` extends CliTests
object web extends Web
def publish0 = publish
class UtilJvm(val crossScalaVersion: String) extends UtilJvmBase {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jsoup
)
}
class UtilJs(val crossScalaVersion: String) extends CsScalaJsModule with Util
class CoreJvm(val crossScalaVersion: String) extends CoreJvmBase {
def moduleDeps = super.moduleDeps ++ Seq(
util.jvm()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.concurrentReferenceHashMap,
Deps.scalaXml
)
object test extends Tests with CsTests {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jol
)
}
}
class CoreJs(val crossScalaVersion: String) extends Core with CsScalaJsModule {
def moduleDeps = super.moduleDeps ++ Seq(
util.js()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaJsDom
)
object test extends Tests with CsTests
}
class CacheJvm(val crossScalaVersion: String) extends CacheJvmBase {
def moduleDeps = Seq(
util.jvm()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jniUtils,
Deps.plexusArchiver,
Deps.plexusContainerDefault,
Deps.windowsAnsi
)
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Deps.svm
)
def sources = T.sources {
super.sources() ++ directories.sources() ++ paths.sources()
}
def resources = T.sources {
super.resources() ++ directories.resources()
}
def customLoaderCp = T {
`custom-protocol-for-test`.runClasspath()
}
object test extends Tests with CsTests {
def ivyDeps = T {
val sv = scalaVersion()
val extra =
if (sv.startsWith("2.12."))
Agg(
Deps.http4sBlazeServer,
Deps.http4sDsl,
Deps.logbackClassic,
Deps.scalaAsync
)
else Agg.empty[Dep]
super.ivyDeps() ++ extra
}
}
}
class CacheJs(val crossScalaVersion: String) extends Cache with CsScalaJsModule {
def moduleDeps = Seq(
util.js()
)
def artifactName = "fetch-js"
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaJsDom
)
}
class Launcher(val crossScalaVersion: String) extends LauncherBase {
def ivyDeps = super.ivyDeps() ++ Seq(
Deps.collectionCompat
)
def compileIvyDeps = Agg(
Deps.dataClass
)
def bootstrap = `bootstrap-launcher`.proguardedAssembly()
def resourceBootstrap = `bootstrap-launcher`.proguardedResourceAssembly()
def noProguardBootstrap = `bootstrap-launcher`.assembly()
def noProguardResourceBootstrap = `bootstrap-launcher`.resourceAssembly()
}
class Publish(val crossScalaVersion: String) extends CrossSbtModule with CsModule
with CoursierPublishModule with CsMima {
def artifactName = "coursier-publish"
def moduleDeps = Seq(
core.jvm(),
cache.jvm()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.argonautShapeless,
Deps.catsCore,
Deps.collectionCompat,
Deps.okhttp
)
def mimaPreviousVersions = T {
val previous = super.mimaPreviousVersions()
if (crossScalaVersion.startsWith("2.13."))
// this module wasn't published in 2.13 when coursier was built with sbt
previous.filter(_ != "2.0.16")
else
previous
}
}
class Env(val crossScalaVersion: String) extends CrossSbtModule with CsModule
with CoursierPublishModule with CsMima {
def artifactName = "coursier-env"
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Deps.dataClass
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.collectionCompat,
Deps.jniUtils
)
object test extends Tests with CsTests {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jimfs
)
}
}
def cliScalaVersion = ScalaVersions.scala212
def launcherModule = launcher
trait LauncherNative03 extends CsModule with CoursierPublishModule {
def artifactName = "coursier-launcher-native_0.3"
def scalaVersion = cliScalaVersion
def compileModuleDeps = Seq(
launcherModule(cliScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaNativeTools03
)
}
trait LauncherNative040M2 extends CsModule with CoursierPublishModule {
def artifactName = "coursier-launcher-native_0.4.0-M2"
def scalaVersion = cliScalaVersion
def compileModuleDeps = Seq(
launcherModule(cliScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaNativeTools040M2
)
}
trait LauncherNative04 extends CsModule with CoursierPublishModule {
def artifactName = "coursier-launcher-native_0.4"
def scalaVersion = cliScalaVersion
def compileModuleDeps = Seq(
launcherModule(cliScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaNativeTools040
)
}
class CoursierJvm(val crossScalaVersion: String) extends CoursierJvmBase { self =>
def moduleDeps = Seq(
core.jvm(),
cache.jvm()
)
// Put CoursierTests right after TestModule, and see what happens
object test extends TestModule with Tests with CoursierTests with CsTests with JvmTests
object it extends TestModule with Tests with CoursierTests with CsTests with JvmTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
)
def moduleDeps = super.moduleDeps ++ Seq(
self.test
)
def forkArgs = T.input {
val testRepoServer0 = workers.testRepoServer()
super.forkArgs() ++ Seq(
s"-Dtest.repository=${testRepoServer0.url}",
s"-Dtest.repository.user=${testRepoServer0.user}",
s"-Dtest.repository.password=${testRepoServer0.password}"
)
}
}
}
class CoursierJs(val crossScalaVersion: String) extends Coursier with CsScalaJsModule {
def moduleDeps = Seq(
core.js(),
cache.js()
)
object test extends Tests with CsTests with JsTests with CoursierTests
}
class TestsJvm(val crossScalaVersion: String) extends TestsModule { self =>
def moduleDeps = super.moduleDeps ++ Seq(
core.jvm()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jsoup
)
object test extends Tests with CsTests with JvmTests {
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm()
)
}
object it extends Tests with CsTests with JvmTests with workers.UsesRedirectingServer {
def redirectingServerCp =
`redirecting-server`.runClasspath()
def redirectingServerMainClass =
`redirecting-server`.mainClass().getOrElse(sys.error("no main class"))
def forkArgs = T.input {
val redirectingServer0 = redirectingServer()
val testRepoServer0 = workers.testRepoServer()
super.forkArgs() ++ Seq(
s"-Dtest.redirect.repository=${redirectingServer0.url}",
s"-Dtest.repository=${testRepoServer0.url}",
s"-Dtest.repository.user=${testRepoServer0.user}",
s"-Dtest.repository.password=${testRepoServer0.password}"
)
}
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
)
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm(),
self.test
)
}
}
class TestsJs(val crossScalaVersion: String) extends TestsModule with CsScalaJsModule {
def moduleDeps = super.moduleDeps ++ Seq(
core.js()
)
// testOptions := testOptions.dependsOn(runNpmInstallIfNeeded).value
object test extends Tests with CsTests with JsTests {
def moduleDeps = super.moduleDeps ++ Seq(
coursier.js()
)
}
}
class ProxyTests(val crossScalaVersion: String) extends CrossSbtModule {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.dockerClient,
Deps.scalaAsync,
Deps.slf4JNop
)
object it extends Tests with CsTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
)
def moduleDeps = super.moduleDeps ++ Seq(
tests.jvm().test
)
def testFramework = "coursier.test.CustomFramework"
}
// sharedTestResources
}
class ScalazJvm(val crossScalaVersion: String) extends Scalaz with CsMima {
def moduleDeps = Seq(
cache.jvm()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalazConcurrent
)
object test extends Tests with CsTests {
def moduleDeps = super.moduleDeps ++ Seq(
tests.jvm().test
)
}
}
class ScalazJs(val crossScalaVersion: String) extends Scalaz with CsScalaJsModule {
def moduleDeps = Seq(
cache.js()
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalazCore
)
}
class CatsJvm(val crossScalaVersion: String) extends Cats with CsMima {
def moduleDeps = Seq(
cache.jvm()
)
object test extends Tests with CsTests {
def moduleDeps = super.moduleDeps ++ Seq(
tests.jvm().test
)
}
}
class CatsJs(val crossScalaVersion: String) extends Cats with CsScalaJsModule {
def moduleDeps = Seq(
cache.js()
)
}
class Install(val crossScalaVersion: String) extends CrossSbtModule with CsModule
with CoursierPublishModule with CsMima {
def mimaPreviousVersions = T {
super.mimaPreviousVersions().filter(_ != "2.0.16")
}
def artifactName = "coursier-install"
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm(),
env(),
jvm(),
launcherModule()
)
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Deps.dataClass
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.argonautShapeless,
Deps.catsCore
)
object test extends Tests with CsTests
}
class Jvm(val crossScalaVersion: String) extends CrossSbtModule with CsModule
with CoursierPublishModule with CsMima {
def mimaPreviousVersions = T {
super.mimaPreviousVersions().filter(_ != "2.0.16")
}
def artifactName = "coursier-jvm"
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm(),
env()
)
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Deps.dataClass,
Deps.jsoniterMacros,
Deps.svm
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.argonautShapeless,
Deps.jsoniterCore
)
object test extends Tests with CsTests
}
trait Cli extends CsModule with CoursierPublishModule with Launchers {
def artifactName = "coursier-cli"
def scalaVersion = cliScalaVersion
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm(cliScalaVersion),
install(cliScalaVersion),
jvm(cliScalaVersion),
launcherModule(cliScalaVersion),
publish0(cliScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.argonautShapeless,
Deps.caseApp,
Deps.catsCore,
Deps.dataClass,
Deps.monadlessCats,
Deps.monadlessStdlib,
Deps.svmSubs,
ivy"com.chuusai::shapeless:2.3.7"
)
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Deps.svm
)
def mainClass = Some("coursier.cli.Coursier")
def finalMainClassOpt = T {
Right("coursier.cli.Coursier"): Either[String, String]
}
def manifest = T {
import java.util.jar.Attributes.Name
val ver = publishVersion()
super.manifest().add(
Name.IMPLEMENTATION_TITLE.toString -> "coursier-cli",
Name.IMPLEMENTATION_VERSION.toString -> ver,
Name.SPECIFICATION_VENDOR.toString -> "io.get-coursier",
Name.SPECIFICATION_TITLE.toString -> "coursier-cli",
Name.IMPLEMENTATION_VENDOR_ID.toString -> "io.get-coursier",
Name.SPECIFICATION_VERSION.toString -> ver,
Name.IMPLEMENTATION_VENDOR.toString -> "io.get-coursier"
)
}
def docJar = T {
val jar = T.dest / "empty.jar"
val baos = new java.io.ByteArrayOutputStream
val zos = new java.util.zip.ZipOutputStream(baos)
zos.finish()
zos.close()
os.write.over(jar, baos.toByteArray)
PathRef(jar)
}
object test extends Tests with CsTests
}
trait CliTests extends CsModule { self =>
def scalaVersion = cliScalaVersion
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm(cliScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.caseApp,
Deps.utest
)
object test extends Tests with CsTests {
def forkArgs = {
val launcherTask = cli.launcher.map(_.path)
T {
super.forkArgs() ++ Seq(
s"-Dcoursier-test-launcher=${launcherTask()}",
"-Dcoursier-test-launcher-accepts-D=false",
"-Dcoursier-test-launcher-accepts-J=false"
)
}
}
}
object `native-tests` extends Tests with CsTests with Bloop.Module {
def skipBloop = true
def sources = T.sources {
super.sources() ++ self.test.sources()
}
def forkArgs = {
val launcherTask = cli.nativeImage.map(_.path)
T {
super.forkArgs() ++ Seq(
s"-Dcoursier-test-launcher=${launcherTask()}",
"-Dcoursier-test-launcher-accepts-D=false",
"-Dcoursier-test-launcher-accepts-J=false"
)
}
}
}
}
def webScalaVersion = ScalaVersions.scala212
trait Web extends CsScalaJsModule {
def scalaVersion = webScalaVersion
// ScalaJSBundlerPlugin
def moduleDeps = super.moduleDeps ++ Seq(
coursier.js(webScalaVersion)
)
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaJsJquery,
Deps.scalaJsReact
)
def moduleKind = mill.scalajslib.api.ModuleKind.CommonJSModule
// scalaJSUseMainModuleInitializer := true
// webpackConfigFile := Some(resourceDirectory.in(Compile).value / "webpack.config.js")
// npmDependencies.in(Compile) ++= Seq(
// "bootstrap" -> "3.3.4",
// "bootstrap-treeview" -> "1.2.0",
// "graphdracula" -> "1.2.1",
// "webpack-raphael" -> "2.1.4",
// "react" -> "16.13.1",
// "react-dom" -> "16.13.1",
// "requirejs" -> "2.3.6",
// "sax" -> "1.2.4"
// )
// browserifyBundle("sax")
}
object `redirecting-server` extends SbtModule {
def scalaVersion = ScalaVersions.scala212
def ivyDeps = Agg(
ivy"org.http4s::http4s-blaze-server:0.17.6",
ivy"org.http4s::http4s-dsl:0.17.6",
ivy"org.http4s::http4s-server:0.17.6"
)
def mainClass = Some("redirectingserver.RedirectingServer")
}
// FIXME Not run… should be moved to cli-tests
def simpleNativeCliTest() = T.command {
`launcher-native_03`.publishLocal()()
`launcher-native_040M2`.publishLocal()()
`launcher-native_04`.publishLocal()()
val launcher = cli.launcher().path
val tmpDir = os.temp.dir(prefix = "coursier-bootstrap-scala-native-test")
val res =
try {
os.proc(
launcher.toString,
"bootstrap",
"-S",
"-o",
"native-echo",
"io.get-coursier:echo_native0.3_2.11:1.0.1"
).call(cwd = tmpDir) // TODO inherit all
os.proc(tmpDir / "native-echo", "-n", "foo", "a").call()
}
finally {
try os.remove.all(tmpDir)
catch {
case _: java.io.IOException =>
System.err.println(s"Error removing $tmpDir, ignoring it")
}
}
assert(res.out.text == "foo a")
}
def copyLauncher(directory: String = "artifacts") = T.command {
val nativeLauncher = cli.nativeImage().path
ghreleaseassets.copyLauncher(nativeLauncher, os.Path(directory, os.pwd))
}
def uploadLaunchers(directory: String = "artifacts") = T.command {
val version = cli.publishVersion()
ghreleaseassets.uploadLaunchers(version, os.Path(directory, os.pwd))
}
def bootstrapLauncher(
version: String = buildVersion,
dest: String = s"coursier$platformBootstrapExtension"
) = T.command {
val extraArgs = if (version.endsWith("SNAPSHOT")) Seq("-r", "sonatype:snapshots") else Nil
cli.run(Seq(
"bootstrap",
"-o",
dest,
"-f",
s"$mavenOrg::coursier-cli:$version",
"--scala",
cliScalaVersion
) ++ extraArgs: _*).map { _ =>
os.Path(dest, os.pwd)
}
}
def assemblyLauncher(version: String = buildVersion, dest: String = "coursier.jar") = T.command {
val extraArgs = if (version.endsWith("SNAPSHOT")) Seq("-r", "sonatype:snapshots") else Nil
cli.run(Seq(
"bootstrap",
"--assembly",
"-o",
dest,
"-f",
s"$mavenOrg::coursier-cli:$version",
"--scala",
cliScalaVersion
) ++ extraArgs: _*).map { _ =>
os.Path(dest, os.pwd)
}
}
def waitForSync(version: String = buildVersion) = T.command {
val launcher = cli.launcher().path
val extraArgs = if (version.endsWith("SNAPSHOT")) Seq("-r", "sonatype:snapshots") else Nil
sync.waitForSync(
launcher.toString,
s"io.get-coursier:coursier-cli_2.12:$version",
extraArgs,
25
)
}
def copyJarLaunchers(version: String = buildVersion, directory: String = "artifacts") = T.command {
val bootstrap: os.Path = bootstrapLauncher(version = version)()
val assembly: os.Path = assemblyLauncher(version = version)()
val dir = os.Path(directory, os.pwd)
os.copy(
bootstrap,
dir / s"coursier$platformBootstrapExtension",
createFolders = true,
replaceExisting = true
)
os.copy(assembly, dir / "coursier.jar", createFolders = true, replaceExisting = true)
}
def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) =
T.command {
val data = define.Task.sequence(tasks.value)()
publishing.publishSonatype(
data = data,
log = T.ctx().log
)
}
private val docScalaVersion = ScalaVersions.scala213
object `doc-deps` extends ScalaModule {
def scalaVersion = docScalaVersion
def moduleDeps = Seq(
coursier.jvm(docScalaVersion),
interop.cats.jvm(docScalaVersion)
)
}
object doc extends Doc {
def scalaVersion = docScalaVersion
def version = coursier.jvm(docScalaVersion).publishVersion()
def classPath = `doc-deps`.runClasspath()
}
def updateWebsite(dryRun: Boolean = false) = {
val docusaurusDir = os.pwd / "doc" / "website"
val versionedDocsRepo = "coursier/versioned-docs"
val versionedDocsBranch = "master"
val versionOpt =
Option(System.getenv("GITHUB_REF"))
.filter(_.startsWith("refs/tags/v"))
.map(_.stripPrefix("refs/tags/v"))
val token =
if (dryRun) ""
else
Option(System.getenv("GH_TOKEN")).getOrElse {
sys.error("GH_TOKEN not set")
}
T.command {
doc.copyVersionedData()()
doc.generate("--npm-install", "--yarn-run-build")()
docs.updateVersionedDocs(
docusaurusDir,
versionedDocsRepo,
versionedDocsBranch,
ghTokenOpt = Some(token),
newVersionOpt = versionOpt,
dryRun = dryRun
)
// copyDemoFiles()
docs.updateGhPages(
docusaurusDir / "build",
token,
"coursier/coursier",
branch = "gh-pages",
dryRun = dryRun
)()
}
}
def jvmTests(scalaVersion: String = "*") = {
def crossTests(sv: String) = Seq(
// format: off
core.jvm .itemMap.get(List(sv)).map(_.test.test()),
cache.jvm .itemMap.get(List(sv)).map(_.test.test()),
env .itemMap.get(List(sv)).map(_.test.test()),
coursier.jvm .itemMap.get(List(sv)).map(_.test.test()),
tests.jvm .itemMap.get(List(sv)).map(_.test.test()),
interop.scalaz.jvm .itemMap.get(List(sv)).map(_.test.test()),
interop.cats.jvm .itemMap.get(List(sv)).map(_.test.test()),
install .itemMap.get(List(sv)).map(_.test.test()),
jvm .itemMap.get(List(sv)).map(_.test.test())
// format: on
).flatten
def crossIts(sv: String) = Seq(
// format: off
coursier.jvm .itemMap.get(List(sv)).map(_.it.test()),
tests.jvm .itemMap.get(List(sv)).map(_.it.test())
// format: on
).flatten
val nonCrossTests = Seq(
// format: off
`bootstrap-launcher` .test .test(),
`bootstrap-launcher` .it .test(),
cli .test .test(),
`cli-tests` .test .test()
// format: on
)
val extraTests =
if (Properties.isWin) Nil
else Seq(simpleNativeCliTest())
val scalaVersions =
if (scalaVersion == "*") ScalaVersions.scala211 +: ScalaVersions.all
else Seq(scalaVersion)
val tasks = nonCrossTests ++
// extraTests ++ // disabled for now (issues on GitHub actions)
scalaVersions.flatMap { sv =>
crossTests(sv) ++ crossIts(sv)
}
T.command {
define.Task.sequence(tasks)()
()
}
}
def jsTests(scalaVersion: String = "*") = {
def crossTests(sv: String) = Seq(
// format: off
core.js .itemMap.get(List(sv)).map(_.test.test()),
coursier.js .itemMap.get(List(sv)).map(_.test.test()),
tests.js .itemMap.get(List(sv)).map(_.test.test())
// format: on
).flatten
val scalaVersions =
if (scalaVersion == "*") ScalaVersions.all
else Seq(scalaVersion)
val tasks = scalaVersions.flatMap(sv => crossTests(sv))
T.command {
define.Task.sequence(tasks)()
}
}
def nativeTests() = T.command {
`cli-tests`.`native-tests`.test()()
}