diff --git a/.config/mill-version b/.config/mill-version index e7fd7ecd910..8347e74eaba 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1 +1 @@ -0.12.5-130-8f256f-DIRTY3537ab30-native +0.12.5-131-1e6358-native \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d905004835a..0dcc448d0b0 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -204,7 +204,7 @@ jobs: include: # bootstrap tests - java-version: 11 # Have one job on oldest JVM - buildcmd: ci/test-mill-dev.sh && ci/test-mill-release.sh && ./mill -i -k __.ivyDepsTree && ./mill -i -k __.ivyDepsTree --withRuntime + buildcmd: ci/test-dist-run.sh && ci/test-install-local.sh && ./mill -i -k __.ivyDepsTree && ./mill -i -k __.ivyDepsTree --withRuntime - java-version: 17 # Have one job on default JVM buildcmd: ci/test-mill-bootstrap.sh diff --git a/ci/test-mill-dev.sh b/ci/test-dist-run.sh similarity index 100% rename from ci/test-mill-dev.sh rename to ci/test-dist-run.sh diff --git a/ci/test-mill-release.sh b/ci/test-install-local.sh similarity index 100% rename from ci/test-mill-release.sh rename to ci/test-install-local.sh diff --git a/dist/package.mill b/dist/package.mill index 75602a7537b..0efefbb4424 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -16,11 +16,11 @@ trait InstallModule extends build.MillPublishJavaModule{ } def moduleDeps = Seq(build.runner, build.idea, build.main.init) - def jar: T[PathRef] + def executableRaw: T[PathRef] def executable = Task{ Task.traverse(allPublishModules)(m => m.publishLocalCached)() - jar() + executableRaw() } def localBinName: String @@ -91,7 +91,13 @@ object `package` extends RootModule with InstallModule { def genTask(m: ScalaModule) = Task.Anon { Seq(m.jar(), m.sourceJar()) ++ m.runClasspath() } - def forkArgs: T[Seq[String]] = Task { + + def localBinName = "mill-assembly.jar" + + def launcher = Task { + val isWin = scala.util.Properties.isWin + val outputPath = Task.dest / (if (isWin) "run.bat" else "run") + val genIdeaArgs = genTask(build.main.define)() ++ genTask(build.main.eval)() ++ @@ -103,21 +109,36 @@ object `package` extends RootModule with InstallModule { genTask(build.javascriptlib)() ++ genTask(build.pythonlib)() - testArgs() ++ + val launcherForkArgs = testArgs() ++ Seq( "-DMILL_CLASSPATH=" + runClasspath().map(_.path.toString).mkString(","), "-DMILL_BUILD_LIBRARIES=" + genIdeaArgs.map(_.path).mkString(","), - s"-DBSP4J_VERSION=${build.Deps.bsp4j.dep.version}" + ) - } + val (millArgs, otherArgs) = + launcherForkArgs.partition(arg => arg.startsWith("-DMILL") && !arg.startsWith("-DMILL_VERSION")) - def localBinName = "mill-assembly.jar" + // Pass Mill options via file, due to small max args limit in Windows + val vmOptionsFile = Task.dest / "mill.properties" + val millOptionsContent = millArgs + .map(_.drop(2).replace("\\", "/")) // drop -D prefix, replace \ with / + .mkString("\r\n") - def launcher = Task { - val isWin = scala.util.Properties.isWin - val outputPath = Task.dest / (if (isWin) "run.bat" else "run") + os.write(vmOptionsFile, millOptionsContent) + val jvmArgs = otherArgs ++ List(s"-DMILL_OPTIONS_PATH=$vmOptionsFile") + val classpath = runClasspath().map(_.path.toString) + val classpathJar = Task.dest / "classpath.jar" + Jvm.createClasspathPassingJar(classpathJar, runClasspath().map(_.path)) + + val script = Jvm.launcherUniversalScript( + mainClass = "mill.runner.client.MillClientMain", + shellClassPath = classpath, + cmdClassPath = Agg(classpathJar.toString()), + jvmArgs = jvmArgs, + ) + + os.write(outputPath, script) - os.write(outputPath, prependShellScript()) if (!isWin) os.perms.set(outputPath, "rwxrwxrwx") PathRef(outputPath) @@ -131,49 +152,21 @@ object `package` extends RootModule with InstallModule { mill.scalalib.Assembly.Rule.ExcludePattern("mill/local-test-overrides/.*") ) - def jar = Task { - val version = build.millVersion() - val devRunClasspath = runClasspath().map(_.path) - val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill" - val commonArgs = Seq( - // Workaround for Zinc/JNA bug - // https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130 - "-Djna.nosys=true" - ) - val shellArgs = Seq("-DMILL_CLASSPATH=$0") ++ commonArgs - val cmdArgs = Seq(""""-DMILL_CLASSPATH=%~dpnx0"""") ++ commonArgs - os.move( - mill.scalalib.Assembly.createAssembly( - devRunClasspath, - prependShellScript = launcherScript(shellArgs, cmdArgs, Agg("$0"), Agg("%~dpnx0")), - assemblyRules = assemblyRules - ).path, - Task.dest / filename - ) - PathRef(Task.dest / filename) - } + def forkArgs = Seq( + // Workaround for Zinc/JNA bug + // https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130 + "-Djna.nosys=true" + ) - def prependShellScript = Task { - val (millArgs, otherArgs) = - forkArgs().partition(arg => arg.startsWith("-DMILL") && !arg.startsWith("-DMILL_VERSION")) - // Pass Mill options via file, due to small max args limit in Windows - val vmOptionsFile = Task.dest / "mill.properties" - val millOptionsContent = - millArgs.map(_.drop(2).replace("\\", "/")).mkString( - "\r\n" - ) // drop -D prefix, replace \ with / - os.write(vmOptionsFile, millOptionsContent) - val jvmArgs = otherArgs ++ List(s"-DMILL_OPTIONS_PATH=$vmOptionsFile") - val classpath = runClasspath().map(_.path.toString) - val classpathJar = Task.dest / "classpath.jar" - Jvm.createClasspathPassingJar(classpathJar, runClasspath().map(_.path)) + def forkShellArgs = Seq("-DMILL_CLASSPATH=$0") + def forkCmdArgs = Seq(""""-DMILL_CLASSPATH=%~dpnx0"""") - launcherScript( - jvmArgs, - jvmArgs, - classpath, - Agg(classpathJar.toString()) // TODO not working yet on Windows! see #791 - ) + def mainClass = Some("mill.runner.client.MillClientMain") + + def executableRaw = Task { + val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill" + os.copy(assembly().path, Task.dest / filename) + PathRef(Task.dest / filename) } def run(args: Task[Args] = Task.Anon(Args())) = Task.Command(exclusive = true) { @@ -195,23 +188,6 @@ object `package` extends RootModule with InstallModule { } } } - def launcherScript( - shellJvmArgs: Seq[String], - cmdJvmArgs: Seq[String], - shellClassPath: Agg[String], - cmdClassPath: Agg[String] - ) = { - - Jvm.launcherUniversalScript( - mainClass = "mill.runner.client.MillClientMain", - shellClassPath = shellClassPath, - cmdClassPath = cmdClassPath, - jvmArgs = Nil, - shebang = false, - shellJvmArgs = shellJvmArgs, - cmdJvmArgs = cmdJvmArgs - ) - } def millBootstrap = Task.Source(Task.workspace / "mill") def millBootstrapBat = Task.Source(Task.workspace / "mill.bat") @@ -266,7 +242,7 @@ object `package` extends RootModule with InstallModule { def uploadToGithub(authKey: String) = Task.Command { val vcsState = VcsVersion.vcsState() - val label = vcsState.format() + val label = vcsState.copy(dirtyHash = None).format() if (label != build.millVersion()) sys.error("Modified mill version detected, aborting upload") val releaseTag = vcsState.lastTag.getOrElse(sys.error( "Incomplete git history. No tag found.\nIf on CI, make sure your git checkout job includes enough history." @@ -318,7 +294,7 @@ object `package` extends RootModule with InstallModule { def localBinName = "mill-native" - def jar = Task { + def executableRaw = Task { val previous = nativeImage().path val executable = Task.dest / previous.baseName diff --git a/integration/ide/bsp-modules/src/BspModulesTests.scala b/integration/ide/bsp-modules/src/BspModulesTests.scala index 8927cef4dd0..1ca196f3dec 100644 --- a/integration/ide/bsp-modules/src/BspModulesTests.scala +++ b/integration/ide/bsp-modules/src/BspModulesTests.scala @@ -5,7 +5,7 @@ import mill.bsp.Constants import utest._ object BspModulesTests extends UtestIntegrationTestSuite { - val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) + val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", Constants.bspProtocolVersion) def tests: Tests = Tests { test("BSP module with foreign modules") { diff --git a/integration/ide/bsp-server/src/BspInstallDebugTests.scala b/integration/ide/bsp-server/src/BspInstallDebugTests.scala index 7458444e6a2..f3a96c8384a 100644 --- a/integration/ide/bsp-server/src/BspInstallDebugTests.scala +++ b/integration/ide/bsp-server/src/BspInstallDebugTests.scala @@ -8,7 +8,7 @@ object BspInstallDebugTests extends UtestIntegrationTestSuite { override protected def workspaceSourcePath: os.Path = super.workspaceSourcePath / "project" - val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) + val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", Constants.bspProtocolVersion) // we purposely enable debugging in this simulated test env override val debugLog: Boolean = true