Skip to content

Commit bdaf5d8

Browse files
authored
Merge pull request #3927 from Gedochao/maintenance/cross-compile-runners
Cross compile the `runner` and `test-runner` modules against Scala 3 Next versions
2 parents 8b45736 + 1193cc7 commit bdaf5d8

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

build.mill.scala

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ object directives extends Cross[Directives](Scala.scala3MainVersions)
104104
object core extends Cross[Core](Scala.scala3MainVersions) with CrossScalaDefaultToInternal
105105
object `build-module` extends Cross[Build](Scala.scala3MainVersions)
106106
with CrossScalaDefaultToInternal
107-
object runner extends Runner
108-
object `test-runner` extends TestRunner
109-
object `tasty-lib` extends Cross[TastyLib](Scala.scala3MainVersions)
107+
object runner extends Cross[Runner](Scala.runnerScalaVersions) with CrossScalaDefaultToRunner
108+
object `test-runner` extends Cross[TestRunner](Scala.runnerScalaVersions)
109+
with CrossScalaDefaultToRunner
110+
object `tasty-lib` extends Cross[TastyLib](Scala.scala3MainVersions)
110111
with CrossScalaDefaultToInternal
111112
// Runtime classes used within native image on Scala 3 replacing runtime from Scala
112113
object `scala3-runtime` extends Cross[Scala3Runtime](Scala.scala3MainVersions)
@@ -436,16 +437,16 @@ trait Core extends ScalaCliCrossSbtModule
436437
def constantsFile: T[PathRef] = Task(persistent = true) {
437438
val dir = Task.dest / "constants"
438439
val dest = dir / "Constants.scala"
439-
val testRunnerMainClass = `test-runner`
440+
val testRunnerMainClass = `test-runner`(crossScalaVersion)
440441
.mainClass()
441442
.getOrElse(sys.error("No main class defined for test-runner"))
442-
val runnerMainClass = build.runner
443+
val runnerMainClass = build.runner(crossScalaVersion)
443444
.mainClass()
444445
.getOrElse(sys.error("No main class defined for runner"))
445446
val detailedVersionValue =
446447
if (`local-repo`.developingOnStubModules) s"""Some("${vcsState()}")"""
447448
else "None"
448-
val testRunnerOrganization = `test-runner`
449+
val testRunnerOrganization = `test-runner`(crossScalaVersion)
449450
.pomSettings()
450451
.organization
451452
val code =
@@ -465,13 +466,13 @@ trait Core extends ScalaCliCrossSbtModule
465466
| def scalaNativeVersion = "${Deps.Versions.scalaNative}"
466467
|
467468
| def testRunnerOrganization = "$testRunnerOrganization"
468-
| def testRunnerModuleName = "${`test-runner`.artifactName()}"
469-
| def testRunnerVersion = "${`test-runner`.publishVersion()}"
469+
| def testRunnerModuleName = "${`test-runner`(crossScalaVersion).artifactName()}"
470+
| def testRunnerVersion = "${`test-runner`(crossScalaVersion).publishVersion()}"
470471
| def testRunnerMainClass = "$testRunnerMainClass"
471472
|
472-
| def runnerOrganization = "${build.runner.pomSettings().organization}"
473-
| def runnerModuleName = "${build.runner.artifactName()}"
474-
| def runnerVersion = "${build.runner.publishVersion()}"
473+
| def runnerOrganization = "${build.runner(crossScalaVersion).pomSettings().organization}"
474+
| def runnerModuleName = "${build.runner(crossScalaVersion).artifactName()}"
475+
| def runnerVersion = "${build.runner(crossScalaVersion).publishVersion()}"
475476
| def runnerScala30LegacyVersion = "${Cli.runnerScala30LegacyVersion}"
476477
| def runnerScala2LegacyVersion = "${Cli.runnerScala2LegacyVersion}"
477478
| def runnerMainClass = "$runnerMainClass"
@@ -726,7 +727,7 @@ trait Build extends ScalaCliCrossSbtModule
726727
options(crossScalaVersion),
727728
directives(crossScalaVersion),
728729
`scala-cli-bsp`,
729-
`test-runner`,
730+
`test-runner`(crossScalaVersion),
730731
`tasty-lib`(crossScalaVersion)
731732
)
732733
override def scalacOptions: T[Seq[String]] = Task {
@@ -1258,33 +1259,24 @@ trait CliIntegrationDocker extends SbtModule with ScalaCliPublishModule with Has
12581259
)
12591260
}
12601261

1261-
trait Runner extends SbtModule
1262+
trait Runner extends CrossSbtModule
12621263
with ScalaCliPublishModule
12631264
with ScalaCliScalafixModule {
1264-
override def scalaVersion: T[String] = Scala.scala3Lts
12651265
override def scalacOptions: T[Seq[String]] = Task {
12661266
super.scalacOptions() ++ Seq("-release", "8", "-deprecation")
12671267
}
12681268
override def mainClass: T[Option[String]] = Some("scala.cli.runner.Runner")
12691269
override def sources: T[Seq[PathRef]] = Task.Sources {
1270-
val scala3DirNames =
1271-
if (scalaVersion().startsWith("3.")) {
1272-
val name =
1273-
if (scalaVersion().contains("-RC")) "scala-3-unstable"
1274-
else "scala-3-stable"
1275-
Seq(name)
1276-
}
1277-
else
1278-
Nil
1279-
val extraDirs = scala3DirNames.map(name => PathRef(moduleDir / "src" / "main" / name))
1270+
val scala3DirName =
1271+
if (crossScalaVersion.contains("-RC")) "scala-3-unstable" else "scala-3-stable"
1272+
val extraDirs = Seq(PathRef(moduleDir / "src" / "main" / scala3DirName))
12801273
super.sources() ++ extraDirs
12811274
}
12821275
}
12831276

1284-
trait TestRunner extends SbtModule
1277+
trait TestRunner extends CrossSbtModule
12851278
with ScalaCliPublishModule
12861279
with ScalaCliScalafixModule {
1287-
override def scalaVersion: T[String] = Scala.scala3Lts
12881280
override def scalacOptions: T[Seq[String]] = Task {
12891281
super.scalacOptions() ++ Seq("-release", "8", "-deprecation")
12901282
}
@@ -1328,9 +1320,10 @@ object `local-repo` extends LocalRepo {
13281320
*/
13291321
def developingOnStubModules = false
13301322

1331-
override def stubsModules: Seq[PublishLocalNoFluff] = Seq(runner, `test-runner`)
1323+
override def stubsModules: Seq[PublishLocalNoFluff] =
1324+
Seq(runner(Scala.runnerScala3), `test-runner`(Scala.runnerScala3))
13321325

1333-
override def version: T[String] = runner.publishVersion()
1326+
override def version: T[String] = runner(Scala.runnerScala3).publishVersion()
13341327
}
13351328

13361329
// Helper CI commands

project/deps/package.mill.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object Scala {
3232
val allScala3 = Seq(scala3Lts, scala3Next, scala3NextAnnounced, scala3NextRc).distinct
3333
val all = (allScala2 ++ allScala3 ++ defaults).distinct
3434
val scala3MainVersions = (defaults ++ allScala3).distinct
35-
val runnerScalaVersions = Seq(runnerScala3, scala213)
35+
val runnerScalaVersions = (Seq(runnerScala3) ++ scala3MainVersions).distinct
3636

3737
def scalaJs = "1.20.1"
3838
def scalaJsCli = scalaJs // this must be compatible with the Scala.js version

0 commit comments

Comments
 (0)