Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.mill.scala
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ trait Cli extends CrossSbtModule with ProtoBuildModule with CliLaunchers
| def defaultMillVersion = "${BuildInfo.millVersion}"
| def mill012Version = "${Deps.Versions.mill012Version}"
| def mill10Version = "${Deps.Versions.mill10Version}"
| def mill11Version = "${Deps.Versions.mill11Version}"
| def defaultSbtVersion = "${Deps.Versions.sbtVersion}"
| def defaultMavenVersion = "${Deps.Versions.mavenVersion}"
| def defaultMavenScalaCompilerPluginVersion = "${Deps.Versions.mavenScalaCompilerPluginVersion}"
Expand Down Expand Up @@ -1122,6 +1123,7 @@ trait CliIntegration extends SbtModule
| def defaultMillVersion = "${BuildInfo.millVersion}"
| def mill012Version = "${Deps.Versions.mill012Version}"
| def mill10Version = "${Deps.Versions.mill10Version}"
| def mill11Version = "${Deps.Versions.mill11Version}"
|}
|""".stripMargin
if (!os.isFile(dest) || os.read(dest) != code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ object Export extends ScalaCommand[ExportOptions] {
cache: FileCache[Task],
projectName: Option[String],
millVersion: String,
useLatestLaunchers: Boolean = true,
logger: Logger
): MillProjectDescriptor = {
val launcherTag = if useLatestLaunchers then "main" else millVersion
val launcherArtifacts = Seq(
os.rel / "mill" -> s"https://github.com/com-lihaoyi/mill/raw/$millVersion/mill",
os.rel / "mill.bat" -> s"https://github.com/com-lihaoyi/mill/raw/$millVersion/mill.bat"
os.rel / "mill" -> s"https://github.com/com-lihaoyi/mill/raw/$launcherTag/mill",
os.rel / "mill.bat" -> s"https://github.com/com-lihaoyi/mill/raw/$launcherTag/mill.bat"
Comment on lines +105 to +108
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To work around com-lihaoyi/mill#6632 / com-lihaoyi/mill#6623, we will now default exported mill launchers to the main branch of the Mill repo, with the option to instead use the version tag hidden behind a flag.
Since export is probably forever an experimental endeavour, and some legacy Mill versions would require using a more recent launcher script anyway, this feels like the lesser evil here.

)
val launcherTasks = launcherArtifacts.map {
case (path, url) =>
Expand Down Expand Up @@ -274,6 +276,7 @@ object Export extends ScalaCommand[ExportOptions] {
cache = options.shared.coursierCache,
projectName = options.project,
millVersion = options.millVersion.getOrElse(Constants.millVersion),
useLatestLaunchers = options.useLatestMillLaunchers.getOrElse(true),
logger = logger
)
else if shouldExportToMaven then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ final case class ExportOptions(
)
millVersion: Option[String] = None,
@Group(HelpGroup.BuildToolExport.toString)
@Tag(tags.restricted)
@HelpMessage(
s"If set, latest Mill launchers from the main branch will be used, rather than the ones for the used version tag (true by default)"
)
useLatestMillLaunchers: Option[Boolean] = None,
@Group(HelpGroup.BuildToolExport.toString)
@Tag(tags.experimental)
@HelpMessage(
s"Version of Maven Compiler Plugin to be used for the export (${Constants.defaultMavenVersion} by default)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ final case class MillProject(
os.write(path0, content, createFolders = true)
}

val outputBuildFile = if isMill1OrNewer then dir / "build.mill.scala" else dir / "build.sc"
val outputBuildFile = if isMill1OrNewer then dir / "build.mill" else dir / "build.sc"
os.write(outputBuildFile, buildFileContent.getBytes(charSet))
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package scala.cli.integration

class ExportMill11Tests212 extends ExportMillTestDefinitions with Test212 with TestMill11
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package scala.cli.integration

class ExportMill11Tests213 extends ExportMillTestDefinitions with Test213 with TestMill11 {
if runExportTests then {
test(s"scalac options$commonTestDescriptionSuffix") {
simpleTest(
inputs = ExportTestProjects.scalacOptionsScala2Test(actualScalaVersion),
mainClass = None,
extraExportArgs = defaultExportCommandArgs
)
}
test(s"pure java$commonTestDescriptionSuffix") {
simpleTest(
inputs = ExportTestProjects.pureJavaTest("ScalaCliJavaTest"),
mainClass = None,
extraExportArgs = defaultExportCommandArgs
)
}
test(s"custom JAR$commonTestDescriptionSuffix") {
simpleTest(
inputs = ExportTestProjects.customJarTest(actualScalaVersion),
mainClass = None,
extraExportArgs = defaultExportCommandArgs
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package scala.cli.integration

class ExportMill11Tests3Lts extends ExportMillTestDefinitions with Test3Lts with TestMill11
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package scala.cli.integration

class ExportMill11TestsDefault extends ExportMillTestDefinitions with TestDefault with TestMill11
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import os.RelPath

import java.nio.charset.Charset

import scala.util.Properties

abstract class ExportMillTestDefinitions extends ScalaCliSuite
with TestScalaVersionArgs
with ExportCommonTestDefinitions
Expand Down Expand Up @@ -104,6 +106,16 @@ abstract class ExportMillTestDefinitions extends ScalaCliSuite
jvmTestScalacOptions(className = "Hello", exportArgs = defaultExportCommandArgs)
}
}
if (!Properties.isMac || TestUtil.isM1) && !Properties.isWin then
// TODO enable this for intel Macs when Mill is bumped to 1.1.0 stable or newer: https://github.com/com-lihaoyi/mill/issues/6632
test(s"JVM scalac options with disabled latest launchers$commonTestDescriptionSuffix") {
TestUtil.retryOnCi() {
jvmTestScalacOptions(
className = "Hello",
exportArgs = defaultExportCommandArgs ++ Seq("--use-latest-mill-launchers=false")
)
}
}
if !actualScalaVersion.startsWith("2.12") then
test(s"JVM with a compiler plugin$commonTestDescriptionSuffix") {
TestUtil.retryOnCi() {
Expand All @@ -121,3 +133,6 @@ trait TestMill012 extends TestMillVersion:
trait TestMill10 extends TestMillVersion:
self: ExportMillTestDefinitions =>
override def millVersion: String = Constants.mill10Version
trait TestMill11 extends TestMillVersion:
self: ExportMillTestDefinitions =>
override def millVersion: String = Constants.mill11Version
2 changes: 2 additions & 0 deletions project/deps/package.mill.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ object Deps {
def mill012Version = "0.12.17"
def mill10Version =
if (BuildInfo.millVersion.startsWith("1.0.")) BuildInfo.millVersion else "1.0.6"
def mill11Version =
if (BuildInfo.millVersion.startsWith("1.1.")) BuildInfo.millVersion else "1.1.0-RC4"
def mavenVersion = "3.8.1"
def mavenScalaCompilerPluginVersion = "4.9.1"
def mavenExecPluginVersion = "3.3.0"
Expand Down
4 changes: 4 additions & 0 deletions website/docs/reference/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ Version of SBT to be used for the export (1.11.7 by default)

Version of Mill to be used for the export (1.0.6 by default)

### `--use-latest-mill-launchers`

If set, latest Mill launchers from the main branch will be used, rather than the ones for the used version tag (true by default)

### `--mvn-version`

Version of Maven Compiler Plugin to be used for the export (3.8.1 by default)
Expand Down
Loading