Repository: scala-steward-org/scala-steward
Pull request #3464 (2024-11-04 21:54:29)

Replace com-lihaoyi/mill/mill script with lefou/millw/millw
This replaces the `mill` script from the Mill project with the script from the dedicated [`millw`](https://github.com/lefou/millw) project.

There is no version of the former script, that properly support all Mill version that Scala Steward can handle.

The `lefou/millw` project supports all Mill version.

Hopefully fix https://github.com/scala-steward-org/scala-steward/issues/3463

I didn't test it locally due to not having set up a test environment for Scala steward. Let me know if that is a deal breaker for you.

mzuehlke: Thanks for taking care of the `mill` support in Scala Steward. I have never used `mill` myself, so I am of no big help here.

The `mill` executable that you are changing is the one bundled into the Docker image. The public instance https://github.com/VirtusLab/scala-steward-repos/ uses this. 
But the https://github.com/scala-steward-org/scala-steward-action/ (maintained by @scala-steward-org/gh-action) use it's own way to get a `mill` executable. 
And the invocation is in both cases the same.

Would the command after the change still work with `mill` or only with `millw` ? 
lefou: Since I can't see the logs of the official instance, I don't know what the issues are there, but I can tell you, that for some of my repos there are no updates for quite some months while other repos work very well. Most repos seeing no updates are in the `com-lihaoyi` org, which could just means, the offical Scala Steward instance doesn't support Mill 0.12 yet.

To see some logs for the very Mill project, I enabled the `scala-steward-action` and identified the issue being a buggy script. If this PR isn't the right location to fix it, I'm grateful for any concrete pointers. I can try to look into https://github.com/scala-steward-org/scala-steward-action/ myself, but it's not really my field of expertise.

> Would the command after the change still work with `mill` or only with `millw` ?

TBH, I'm not sure how to read this question. 

First, `millw` can be renamed to `mill`, which is in fact the typical usage. (I only keep the `millw` name, to be able to distinguish in the communication.)

`millw` is a drop-in replacement for `mill`, accepting all parameters as `mill` does and any kind of version selection (`.mill-version` file, `.config/mill-version` file, `MILL_VERSION` env var, `DEFAULT_MILL_VERSION` env var). It especially supports older Mill version down to `0.3.x`. In fact, most Mill users just install `millw` into `$HOME/bin/mill` and never use the local `./mill` script you can find in many projects.

In contrast, the recent `mill` script of the Mill repo only supports the latest Mill versions, and older versions of that script don't fully support newer Mill releases.

Although I think the peculiar issue #3463 is only present in a small set of releases of the  `mill` script and definitely fixed in more recent versions, it's is still advisable to use `millw` instead, due to the better backward compatibility story. And since Scala Steward is all about updating older projects, it's important to be able to read those older projects. The Mill plugin Scala Steward uses, is still able to read Mill projects from version `0.6.0` upwards. So we should ensure the actual runner also works.

If you meant the other change I did (use of the `--no-server` instead of `-i`), it is just some house keeping, as the `--no-server` option is what we really want to use. I can split out that change, if you like.


Patch:
diff --git a/build.sbt b/build.sbt
index ac69f479..887ee170 100644
--- a/build.sbt
+++ b/build.sbt
@@ -356,14 +356,10 @@ lazy val dockerSettings = Def.settings(
       s"tar -xf $sbtTgz",
       s"rm -f $sbtTgz"
     ).mkString(" && ")
-    val millVer = Dependencies.millScriptVersion
+    val millVer = Dependencies.millwScriptVersion
     val millBin = s"$binDir/mill"
-    val releasePageVersion = millVer.split("-") match {
-      case Array(v, m, _*) if m.startsWith("M") => s"${v}-${m}"
-      case Array(v, _*)                         => v
-    }
     val installMill = Seq(
-      s"$curl $millBin https://github.com/lihaoyi/mill/releases/download/${releasePageVersion}/$millVer",
+      s"$curl $millBin https://github.com/lefou/millw/releases/download/${millVer}/millw-${millVer}",
       s"chmod +x $millBin"
     ).mkString(" && ")
     val csBin = s"$binDir/cs"
diff --git a/modules/core/src/main/scala/org/scalasteward/core/buildtool/mill/MillAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/buildtool/mill/MillAlg.scala
index e058b333..dfe15946 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/buildtool/mill/MillAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/buildtool/mill/MillAlg.scala
@@ -46,7 +46,8 @@ final class MillAlg[F[_]](defaultResolver: Resolver)(implicit
       )
 
   private def runMill(buildRootDir: File) = {
-    val command = Nel("mill", List("-i", "--import", cliPluginCoordinate, "show", extractDeps))
+    val command =
+      Nel("mill", List("--no-server", "--import", cliPluginCoordinate, "show", extractDeps))
     processAlg.execSandboxed(command, buildRootDir)
   }
   private def runMillUnder011(buildRootDir: File, millBuildVersion: Option[Version]) = {
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index a6763fc7..6c2d89c5 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -14,7 +14,7 @@ object Dependencies {
   val circeParser = "io.circe" %% "circe-parser" % circeGeneric.revision
   val circeRefined = "io.circe" %% "circe-refined" % "0.15.1"
   val commonsIo = "commons-io" % "commons-io" % "2.17.0"
-  val coursierCore = "io.get-coursier" %% "coursier" % "2.1.14"
+  val coursierCore = "io.get-coursier" %% "coursier" % "2.1.16"
   val coursierSbtMaven =
     "io.get-coursier" %% "coursier-sbt-maven-repository" % coursierCore.revision
   val cron4sCore = "com.github.alonsodomin.cron4s" %% "cron4s-core" % "0.7.0"
@@ -33,7 +33,7 @@ object Dependencies {
   val jjwtApi = "io.jsonwebtoken" % "jjwt-api" % "0.12.6"
   val jjwtImpl = "io.jsonwebtoken" % "jjwt-impl" % jjwtApi.revision
   val jjwtJackson = "io.jsonwebtoken" % "jjwt-jackson" % jjwtApi.revision
-  val millScriptVersion = "0.11.0-M10"
+  val millwScriptVersion = "0.4.12"
   val monocleCore = "dev.optics" %% "monocle-core" % "3.3.0"
   val munit = "org.scalameta" %% "munit" % "1.0.2"
   val munitCatsEffect = "org.typelevel" %% "munit-cats-effect" % "2.0.0"
diff --git a/project/build.properties b/project/build.properties
index 09feeeed..db1723b0 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1,1 +1,1 @@
-sbt.version=1.10.4
+sbt.version=1.10.5


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/buildtool/mill/MillAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/buildtool/mill/MillAlgTest.scala
index c2969b4b..65ce9025 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/buildtool/mill/MillAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/buildtool/mill/MillAlgTest.scala
@@ -39,7 +39,7 @@ class MillAlgTest extends FunSuite {
     val millCmd = Cmd.execSandboxed(
       repoDir,
       "mill",
-      "-i",
+      "--no-server",
       "--import",
       "ivy:org.scala-steward::scala-steward-mill-plugin::0.18.0",
       "show",