Skip to content

Commit 232e31a

Browse files
authored
Merge branch 'main' into code-review
2 parents 9bca062 + 58981a4 commit 232e31a

File tree

348 files changed

+2652
-2933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

348 files changed

+2652
-2933
lines changed

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ jobs:
243243
include:
244244
# bootstrap tests
245245
- java-version: 11 # Have one job on oldest JVM
246-
buildcmd: ci/test-dist-run.sh && ci/test-install-local.sh && ./mill -i -k __.ivyDepsTree && ./mill -i -k __.ivyDepsTree --withRuntime
246+
buildcmd: ci/test-dist-run.sh && ci/test-install-local.sh && ./mill -i -k __:^IntegrationCrossModule:^TestModule.ivyDepsTree && ./mill -i -k __:^IntegrationCrossModule:^TestModule.ivyDepsTree --withRuntime
247247
- java-version: 17 # Have one job on default JVM
248248
buildcmd: ci/test-mill-bootstrap.sh
249249

bsp/src/mill/bsp/BSP.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package mill.bsp
22

33
import mill.api.{Ctx, PathRef}
4-
import mill.{Agg, T, Task, given}
4+
import mill.{T, Task, given}
55
import mill.define.{Command, Discover, ExternalModule}
66
import mill.main.BuildInfo
77
import mill.eval.Evaluator
@@ -12,7 +12,7 @@ object BSP extends ExternalModule with CoursierModule {
1212

1313
lazy val millDiscover = Discover[this.type]
1414

15-
private def bspWorkerLibs: T[Agg[PathRef]] = Task {
15+
private def bspWorkerLibs: T[Seq[PathRef]] = Task {
1616
millProjectModule("mill-bsp-worker", repositoriesTask())
1717
}
1818

bsp/src/mill/bsp/BspContext.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package mill.bsp
22

3-
import mill.api.{DummyInputStream, Logger, SystemStreams}
3+
import mill.api.{DummyInputStream, Logger, Result, SystemStreams}
44

55
import java.io.PrintStream
66
import scala.util.control.NonFatal
@@ -27,10 +27,7 @@ private[mill] class BspContext(
2727
streams = streams,
2828
logStream = bspLogStream,
2929
canReload = true
30-
) match {
31-
case Left(err) => sys.error(err)
32-
case Right(res) => res
33-
}
30+
).get
3431
} catch {
3532
case NonFatal(e) =>
3633
streams.err.println(s"Could not start BSP server. ${e.getMessage}")
@@ -43,7 +40,7 @@ private[mill] class BspContext(
4340
streams: SystemStreams,
4441
logStream: Option[PrintStream],
4542
canReload: Boolean
46-
): Either[String, BspServerHandle] = {
43+
): Result[BspServerHandle] = {
4744
val log: Logger = new Logger {
4845
override def colored: Boolean = false
4946
override def systemStreams: SystemStreams = new SystemStreams(

bsp/src/mill/bsp/BspWorker.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package mill.bsp
22

3-
import mill.api.{Logger, SystemStreams}
3+
import mill.api.{Logger, SystemStreams, Result}
44

55
import java.io.PrintStream
66
import java.net.URL
@@ -13,7 +13,7 @@ private trait BspWorker {
1313
logStream: PrintStream,
1414
logDir: os.Path,
1515
canReload: Boolean
16-
): Either[String, BspServerHandle]
16+
): Result[BspServerHandle]
1717
}
1818

1919
private object BspWorker {
@@ -25,9 +25,9 @@ private object BspWorker {
2525
home0: os.Path,
2626
log: Logger,
2727
workerLibs: Option[Seq[URL]] = None
28-
): Either[String, BspWorker] = boundary {
28+
): Result[BspWorker] = boundary {
2929
worker match {
30-
case Some(x) => Right(x)
30+
case Some(x) => Result.Success(x)
3131
case None =>
3232
val urls = workerLibs.map { urls =>
3333
log.debug("Using direct submitted worker libs")
@@ -36,7 +36,7 @@ private object BspWorker {
3636
// load extra classpath entries from file
3737
val resources = s"${Constants.serverName}-${mill.main.BuildInfo.millVersion}.resources"
3838
val cpFile = workspace / Constants.bspDir / resources
39-
if (!os.exists(cpFile)) boundary.break(Left(
39+
if (!os.exists(cpFile)) boundary.break(Result.Failure(
4040
"You need to run `mill mill.bsp.BSP/install` before you can use the BSP server"
4141
))
4242

@@ -54,7 +54,7 @@ private object BspWorker {
5454
val ctr = workerCls.getConstructor()
5555
val workerImpl = ctr.newInstance().asInstanceOf[BspWorker]
5656
worker = Some(workerImpl)
57-
Right(workerImpl)
57+
Result.Success(workerImpl)
5858
}
5959
}
6060

bsp/worker/src/mill/bsp/worker/BspWorkerImpl.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ch.epfl.scala.bsp4j.BuildClient
44
import mill.main.BuildInfo
55
import mill.bsp.{BspServerHandle, BspServerResult, BspWorker, Constants}
66
import mill.eval.Evaluator
7-
import mill.api.SystemStreams
7+
import mill.api.{Result, SystemStreams}
88
import org.eclipse.lsp4j.jsonrpc.Launcher
99

1010
import java.io.{PrintStream, PrintWriter}
@@ -20,7 +20,7 @@ private class BspWorkerImpl() extends BspWorker {
2020
logStream: PrintStream,
2121
logDir: os.Path,
2222
canReload: Boolean
23-
): Either[String, BspServerHandle] = {
23+
): mill.api.Result[BspServerHandle] = {
2424

2525
val millServer =
2626
new MillBuildServer(
@@ -90,12 +90,12 @@ private class BspWorkerImpl() extends BspWorker {
9090
executor.shutdown()
9191
}).start()
9292

93-
Right(bspServerHandle)
93+
Result.Success(bspServerHandle)
9494
} catch {
9595
case _: CancellationException =>
96-
Left("The mill server was shut down.")
96+
Result.Failure("The mill server was shut down.")
9797
case e: Exception =>
98-
Left(
98+
Result.Failure(
9999
s"""An exception occurred while connecting to the client.
100100
|Cause: ${e.getCause}
101101
|Message: ${e.getMessage}

bsp/worker/src/mill/bsp/worker/MillBuildServer.scala

+13-20
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ package mill.bsp.worker
33
import ch.epfl.scala.bsp4j
44
import ch.epfl.scala.bsp4j._
55
import com.google.gson.JsonObject
6-
import mill.api.Loose.Agg
7-
import mill.api.{
8-
ColorLogger,
9-
CompileProblemReporter,
10-
DummyTestReporter,
11-
Result,
12-
Strict,
13-
TestReporter
14-
}
6+
7+
import mill.api.ExecResult
8+
import mill.api.{ColorLogger, CompileProblemReporter, DummyTestReporter, Result, TestReporter}
159
import mill.bsp.{BspServerResult, Constants}
1610
import mill.bsp.worker.Utils.{makeBuildTarget, outputPaths, sanitizeUri}
1711
import mill.define.Segment.Label
@@ -273,7 +267,7 @@ private class MillBuildServer(
273267
}.toSeq
274268

275269
val ids = groupList(tasksEvaluators)(_._2)(_._1)
276-
.flatMap { case (ev, ts) => ev.evalOrThrow()(ts) }
270+
.flatMap { case (ev, ts) => ev.evaluateValues(ts) }
277271
.flatten
278272

279273
new InverseSourcesResult(ids.asJava)
@@ -479,7 +473,7 @@ private class MillBuildServer(
479473
val runTask = module.run(Task.Anon(Args(args)))
480474
val runResult = evaluate(
481475
ev,
482-
Strict.Agg(runTask),
476+
Seq(runTask),
483477
Utils.getBspLoggedReporterPool(runParams.getOriginId, state.bspIdByModule, client),
484478
logger = new MillBspLogger(client, runTask.hashCode(), ev.baseLogger)
485479
)
@@ -544,7 +538,7 @@ private class MillBuildServer(
544538

545539
val results = evaluate(
546540
ev,
547-
Strict.Agg(testTask),
541+
Seq(testTask),
548542
Utils.getBspLoggedReporterPool(
549543
testParams.getOriginId,
550544
state.bspIdByModule,
@@ -605,16 +599,15 @@ private class MillBuildServer(
605599
val cleanTask = mainModule.clean(ev, Seq(compileTargetName)*)
606600
val cleanResult = evaluate(
607601
ev,
608-
Strict.Agg(cleanTask),
602+
Seq(cleanTask),
609603
logger = new MillBspLogger(client, cleanTask.hashCode, ev.baseLogger)
610604
)
611605
if (cleanResult.failing.size > 0) (
612606
msg + s" Target ${compileTargetName} could not be cleaned. See message from mill: \n" +
613607
(cleanResult.results(cleanTask) match {
614-
case TaskResult(Result.Failure(msg, _), _) => msg
615-
case TaskResult(ex: Result.Exception, _) => ex.toString()
616-
case TaskResult(Result.Skipped, _) => "Task was skipped"
617-
case TaskResult(Result.Aborted, _) => "Task was aborted"
608+
case TaskResult(ex: ExecResult.Exception, _) => ex.toString()
609+
case TaskResult(ExecResult.Skipped, _) => "Task was skipped"
610+
case TaskResult(ExecResult.Aborted, _) => "Task was aborted"
618611
case _ => "could not retrieve the failure message"
619612
}),
620613
false
@@ -680,7 +673,7 @@ private class MillBuildServer(
680673
.map { case ((ev, id), ts) =>
681674
val results = evaluate(ev, ts)
682675
val failures = results.results.collect {
683-
case (_, TaskResult(res: Result.Failing[_], _)) => res
676+
case (_, TaskResult(res: ExecResult.Failing[_], _)) => res
684677
}
685678

686679
def logError(errorMsg: String): Unit = {
@@ -807,7 +800,7 @@ private class MillBuildServer(
807800

808801
private def evaluate(
809802
evaluator: Evaluator,
810-
goals: Agg[Task[?]],
803+
goals: Seq[Task[?]],
811804
reporter: Int => Option[CompileProblemReporter] = _ => Option.empty[CompileProblemReporter],
812805
testReporter: TestReporter = DummyTestReporter,
813806
logger: ColorLogger = null
@@ -823,7 +816,7 @@ private class MillBuildServer(
823816
},
824817
streams = logger0.systemStreams
825818
) {
826-
evaluator.evaluate(
819+
evaluator.execution.executeTasks(
827820
goals,
828821
reporter,
829822
testReporter,

bsp/worker/src/mill/bsp/worker/MillScalaBuildServer.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ch.epfl.scala.bsp4j.{
1313
ScalacOptionsParams,
1414
ScalacOptionsResult
1515
}
16-
import mill.{Agg, Task}
16+
import mill.Task
1717
import mill.bsp.worker.Utils.sanitizeUri
1818
import mill.util.Jvm
1919
import mill.scalalib.{JavaModule, ScalaModule, TestModule, UnresolvedPath}
@@ -41,7 +41,7 @@ private trait MillScalaBuildServer extends ScalaBuildServer { this: MillBuildSer
4141
val compileClasspathTask =
4242
if (enableJvmCompileClasspathProvider) {
4343
// We have a dedicated request for it
44-
Task.Anon { Agg.empty[UnresolvedPath] }
44+
Task.Anon { Seq.empty[UnresolvedPath] }
4545
} else {
4646
m.bspCompileClasspath
4747
}
@@ -119,7 +119,7 @@ private trait MillScalaBuildServer extends ScalaBuildServer { this: MillBuildSer
119119
}
120120
) {
121121
case (ev, state, id, m: TestModule, Some((classpath, testFramework, testClasspath))) =>
122-
val (frameworkName, classFingerprint): (String, Agg[(Class[?], Fingerprint)]) =
122+
val (frameworkName, classFingerprint): (String, Seq[(Class[?], Fingerprint)]) =
123123
Jvm.withClassLoader(
124124
classPath = classpath.map(_.path).toVector,
125125
sharedPrefixes = Seq("sbt.testing.")
@@ -128,7 +128,7 @@ private trait MillScalaBuildServer extends ScalaBuildServer { this: MillBuildSer
128128
val discoveredTests = TestRunnerUtils.discoverTests(
129129
classLoader,
130130
framework,
131-
Agg.from(testClasspath.map(_.path))
131+
Seq.from(testClasspath.map(_.path))
132132
)
133133
(framework.name(), discoveredTests)
134134
}: @unchecked

bsp/worker/src/mill/bsp/worker/Utils.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ch.epfl.scala.bsp4j.{
1111
TaskId
1212
}
1313
import mill.api.{CompileProblemReporter, PathRef}
14-
import mill.api.Result.{Skipped, Success}
14+
import mill.api.ExecResult.{Skipped, Success}
1515
import mill.exec.ExecResults
1616
import mill.scalalib.JavaModule
1717
import mill.scalalib.bsp.{BspBuildTarget, BspModule}

build.mill

+2-1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ trait MillJavaModule extends JavaModule {
392392
}
393393

394394
def testIvyDeps: T[Agg[Dep]] = Agg(Deps.TestDeps.utest)
395+
def testForkEnv: T[Map[String, String]] = forkEnv()
395396
def testModuleDeps: Seq[JavaModule] =
396397
if (this == build.main) Seq(build.main)
397398
else Seq(this, build.main.test)
@@ -540,7 +541,7 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
540541
def forkArgs = super.forkArgs() ++ outer.testArgs()
541542
def moduleDeps = outer.testModuleDeps
542543
def ivyDeps = super.ivyDeps() ++ outer.testIvyDeps()
543-
def forkEnv = super.forkEnv() ++ outer.forkEnv()
544+
def forkEnv = super.forkEnv() ++ outer.testForkEnv()
544545
override def testForkGrouping = discoveredTestClasses().grouped(1).toSeq
545546
}
546547
}

ci/mill-bootstrap.patch

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/build.mill b/build.mill
2-
index 7a8ea3a31a5..5b77aa31591 100644
2+
index 019adfc8cb9..c9df11158ef 100644
33
--- a/build.mill
44
+++ b/build.mill
55
@@ -1,16 +1,16 @@
@@ -65,7 +65,25 @@ index 7a8ea3a31a5..5b77aa31591 100644
6565
def scalaVersion = Deps.scalaVersion
6666
def scalapVersion: T[String] = Deps.scala2Version
6767
def scalafixScalaBinaryVersion = T {
68-
@@ -535,7 +535,7 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
68+
@@ -520,8 +520,8 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
69+
val binaryVersion = ZincWorkerUtil.scalaBinaryVersion(sv)
70+
val hasModuleDefs = binaryVersion == "2.13" || binaryVersion == "3"
71+
super.scalacPluginIvyDeps() ++
72+
- Agg.when(binaryVersion != "3")(Deps.acyclic) ++
73+
- Agg.when(hasModuleDefs)(Deps.millModuledefsPlugin)
74+
+ Option.when(binaryVersion != "3")(Deps.acyclic) ++
75+
+ Option.when(hasModuleDefs)(Deps.millModuledefsPlugin)
76+
}
77+
78+
def mandatoryIvyDeps = T {
79+
@@ -529,13 +529,13 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
80+
val binaryVersion = ZincWorkerUtil.scalaBinaryVersion(sv)
81+
val hasModuleDefs = binaryVersion == "2.13" || binaryVersion == "3"
82+
super.mandatoryIvyDeps() ++
83+
- Agg.when(hasModuleDefs)(Deps.millModuledefs)
84+
+ Option.when(hasModuleDefs)(Deps.millModuledefs)
85+
}
86+
6987
/** Default tests module. */
7088
lazy val test: MillScalaTests = new MillScalaTests {}
7189
trait MillScalaTests extends ScalaTests with MillJavaModule with MillBaseTestsModule
@@ -94,7 +112,7 @@ index 7a8ea3a31a5..5b77aa31591 100644
94112

95113
object bridge extends Cross[BridgeModule](compilerBridgeScalaVersions)
96114
diff --git a/contrib/package.mill b/contrib/package.mill
97-
index 421b2955955..7277bba90ff 100644
115+
index 421b2955955..30c453234b9 100644
98116
--- a/contrib/package.mill
99117
+++ b/contrib/package.mill
100118
@@ -3,13 +3,12 @@ package build.contrib
@@ -141,6 +159,15 @@ index 421b2955955..7277bba90ff 100644
141159
}
142160

143161
def scalaVersion = build.Deps.play(playBinary).scalaVersion
162+
@@ -139,7 +138,7 @@ object `package` extends RootModule {
163+
build.Deps.scalacScoverage2Reporter,
164+
build.Deps.scalacScoverage2Domain,
165+
build.Deps.scalacScoverage2Serializer
166+
- ) ++ Agg.when(!ZincWorkerUtil.isScala3(scalaVersion()))(build.Deps.scalacScoverage2Plugin)
167+
+ ) ++ Option.when(!ZincWorkerUtil.isScala3(scalaVersion()))(build.Deps.scalacScoverage2Plugin)
168+
}
169+
def mandatoryIvyDeps = Agg.empty[Dep]
170+
}
144171
diff --git a/core/codesig/package.mill b/core/codesig/package.mill
145172
index e49f218f4be..9d03aa073f3 100644
146173
--- a/core/codesig/package.mill
@@ -518,6 +545,19 @@ index af00b40d3f0..303bb74cbc0 100644
518545
trait IntegrationCrossModule extends build.MillScalaModule with IntegrationTestModule {
519546
override def moduleDeps = super[IntegrationTestModule].moduleDeps
520547
def forkEnv = super.forkEnv() ++ Seq(
548+
diff --git a/main/package.mill b/main/package.mill
549+
index 08980f56dda..fe819532072 100644
550+
--- a/main/package.mill
551+
+++ b/main/package.mill
552+
@@ -63,7 +63,7 @@ object `package` extends RootModule with build.MillStableScalaModule with BuildI
553+
build.dist.resolutionCustomizer(),
554+
Some(Task.ctx()),
555+
build.dist.coursierCacheCustomizer()
556+
- ).getOrThrow.minDependencies.toSeq
557+
+ ).get.minDependencies.toSeq
558+
// change to this when bumping Mill
559+
// ).getOrThrow.minDependencies.toSeq
560+
.map(d => s"${d.module.organization.value}:${d.module.name.value}:${d.version}")
521561
diff --git a/mill-build/build.mill b/mill-build/build.mill
522562
index 957d929826d..112f1aaccb8 100644
523563
--- a/mill-build/build.mill

contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class BloopImpl(evs: () => Seq[Evaluator], wd: os.Path) extends ExternalModule {
191191

192192
val classpath = Task.Anon {
193193
val transitiveCompileClasspath = Task.traverse(module.transitiveModuleCompileModuleDeps)(m =>
194-
Task.Anon { m.localCompileClasspath().map(_.path) ++ Agg(classes(m)) }
194+
Task.Anon { m.localCompileClasspath().map(_.path) ++ Seq(classes(m)) }
195195
)().flatten
196196

197197
module.resolvedIvyDeps().map(_.path) ++

0 commit comments

Comments
 (0)