From 8d90802687db3194fac69d8b21468dc9acf1bc87 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Thu, 28 Nov 2024 21:57:41 +0530 Subject: [PATCH 01/61] Added task to build mill native image --- build.mill | 1 + dist/package.mill | 78 ++++++++++++++++++- .../native-image/reachability-metadata.json | 10 +++ .../runner/client/MillProcessLauncher.java | 5 ++ scalalib/src/mill/scalalib/Lib.scala | 1 - 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 dist/resources/META-INF/native-image/reachability-metadata.json diff --git a/build.mill b/build.mill index a31c6e6b78b..e313cbe4de8 100644 --- a/build.mill +++ b/build.mill @@ -43,6 +43,7 @@ object Settings { val mimaBaseVersions: Seq[String] = 0.to(13).map("0.11." + _) ++ Seq("0.12.0", "0.12.1", "0.12.2", "0.12.3") + val graalVmJvmId = "graalvm-community:23.0.1" } object Deps { diff --git a/dist/package.mill b/dist/package.mill index b6e11ad33f3..a57ca22c35f 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -1,10 +1,13 @@ package build.dist import mill._, scalalib._, publish._ +import mill.define.ModuleRef import mill.util.Jvm import mill.api.JarManifest import de.tobiasroeser.mill.vcs.version.VcsVersion import $file.ci.upload +import scala.util.{Properties, Using} + object `package` extends RootModule with build.MillPublishJavaModule { /** @@ -157,7 +160,7 @@ object `package` extends RootModule with build.MillPublishJavaModule { def run(args: Task[Args] = Task.Anon(Args())) = Task.Command(exclusive = true) { args().value match { - case Nil => mill.api.Result.Failure("Need to pass in cwd as first argument to dev.run") + case Nil => mill.api.Result.Failure("Need to pass in cwd as first argument to dist.run") case wd0 +: rest => val wd = os.Path(wd0, Task.workspace) os.makeDir.all(wd) @@ -342,4 +345,77 @@ object `package` extends RootModule with build.MillPublishJavaModule { ) } } + + def mainClass = Some("mill.runner.client.MillClientMain") + + def native: T[PathRef] = Task { + val executable = Task.dest / "mill" + + Task.traverse(allPublishModules)(m => m.publishLocalCached)() + + Using(os.write.outputStream( + executable, + if (Properties.isWin) null else "rwxrwxrwx", + createFolders = true) + ) { out => + // concatenate native image and assembly as prescribed in: + // https://github.com/com-lihaoyi/mill/issues/4007#issuecomment-2495933167 + out.write(os.read.bytes(nativeImage().path)) + out.write(System.lineSeparator.getBytes) + out.write(os.read.bytes(super.assembly().path)) + out.flush() + } + + PathRef(executable) + } + + def nativeImage: T[PathRef] = Task { + val dest = T.dest + + val program = zincWorker().javaHome() match { + case None => + throw new RuntimeException("zincWorker javaHome not found") + case Some(home) => + (home.path / "bin/native-image").toString + } + val classPath = runClasspath().iterator + .map(_.path) + .mkString(java.io.File.pathSeparator) + val executableName = "mill-native" + (if (Properties.isWin) ".exe" else "") + + val command = + Seq(program) ++ + Seq("--class-path", classPath) ++ + nativeImageOptions() ++ + Seq(finalMainClass(), executableName) + + T.log.info(s"building native image $executableName") + os.proc(command).call(cwd = dest) + + PathRef(dest / executableName) + } + + def nativeImageOptions: T[Seq[String]] = 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) + Seq.newBuilder[String] + .+=("--no-fallback") + .+=("-H:IncludeResources=logback.xml") + .+=(s"-DMILL_OPTIONS_PATH=$vmOptionsFile") + .++=(otherArgs) + .result() + } + + def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + + object ZincWorkerModuleGraalVm extends ZincWorkerModule { + def jvmId = build.Settings.graalVmJvmId + } } diff --git a/dist/resources/META-INF/native-image/reachability-metadata.json b/dist/resources/META-INF/native-image/reachability-metadata.json new file mode 100644 index 00000000000..8de767df2af --- /dev/null +++ b/dist/resources/META-INF/native-image/reachability-metadata.json @@ -0,0 +1,10 @@ +{ + "reflection": [ + { + "type": "mill.runner.MillMain" + }, + { + "type": "mill.runner.MillServerMain" + } + ] +} \ No newline at end of file diff --git a/runner/client/src/mill/runner/client/MillProcessLauncher.java b/runner/client/src/mill/runner/client/MillProcessLauncher.java index 641b078ebeb..9f5ef6bde2a 100644 --- a/runner/client/src/mill/runner/client/MillProcessLauncher.java +++ b/runner/client/src/mill/runner/client/MillProcessLauncher.java @@ -145,6 +145,11 @@ static String[] millClasspath() throws Exception { selfJars = System.getProperty("java.class.path").replace(File.pathSeparator, ","); } + if (selfJars == null || selfJars.trim().isEmpty()) { + // Assuming native assembly run + selfJars = MillProcessLauncher.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + } + if (selfJars == null || selfJars.trim().isEmpty()) { throw new RuntimeException("MILL_CLASSPATH is empty!"); } diff --git a/scalalib/src/mill/scalalib/Lib.scala b/scalalib/src/mill/scalalib/Lib.scala index cf4fd6330d8..596723fe6e2 100644 --- a/scalalib/src/mill/scalalib/Lib.scala +++ b/scalalib/src/mill/scalalib/Lib.scala @@ -256,7 +256,6 @@ object Lib { Util.millProperty(EnvVars.MILL_BUILD_LIBRARIES) match { case Some(found) => found.split(',').map(os.Path(_)).distinct.toList case None => - millAssemblyEmbeddedDeps val Result.Success(res) = scalalib.Lib.resolveDependencies( repositories = repos.toList, deps = millAssemblyEmbeddedDeps, From 4708b3809afaac2e462a14c2dc2e63a60a7ed545 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Fri, 29 Nov 2024 00:02:48 +0530 Subject: [PATCH 02/61] Added examples for building native image --- docs/modules/ROOT/pages/javalib/intro.adoc | 2 + docs/modules/ROOT/pages/kotlinlib/intro.adoc | 4 ++ docs/modules/ROOT/pages/scalalib/intro.adoc | 4 ++ .../javalib/basic/7-native-image/build.mill | 56 ++++++++++++++++++ .../foo/src/foo/HelloWorld.java | 8 +++ .../kotlinlib/basic/7-native-image/build.mill | 59 +++++++++++++++++++ .../7-native-image/foo/src/foo/HelloWorld.kt | 5 ++ .../scalalib/basic/7-native-image/build.mill | 58 ++++++++++++++++++ .../foo/src/foo/HelloWorld.scala | 7 +++ 9 files changed, 203 insertions(+) create mode 100644 example/javalib/basic/7-native-image/build.mill create mode 100644 example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java create mode 100644 example/kotlinlib/basic/7-native-image/build.mill create mode 100644 example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt create mode 100644 example/scalalib/basic/7-native-image/build.mill create mode 100644 example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala diff --git a/docs/modules/ROOT/pages/javalib/intro.adoc b/docs/modules/ROOT/pages/javalib/intro.adoc index 7683cd7796f..b6d0679112c 100644 --- a/docs/modules/ROOT/pages/javalib/intro.adoc +++ b/docs/modules/ROOT/pages/javalib/intro.adoc @@ -31,4 +31,6 @@ include::partial$example/javalib/basic/4-compat-modules.adoc[] include::partial$example/javalib/basic/6-realistic.adoc[] +== Building Native Image with Graal VM +include::partial$example/javalib/basic/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/kotlinlib/intro.adoc b/docs/modules/ROOT/pages/kotlinlib/intro.adoc index 6de8bc33ee7..57d53d5269f 100644 --- a/docs/modules/ROOT/pages/kotlinlib/intro.adoc +++ b/docs/modules/ROOT/pages/kotlinlib/intro.adoc @@ -36,6 +36,10 @@ include::partial$example/kotlinlib/basic/4-compat-modules.adoc[] include::partial$example/kotlinlib/basic/6-realistic.adoc[] +== Building Native Image with Graal VM + +include::partial$example/kotlinlib/basic/7-native-image.adoc[] + == History Mill's Kotlin support originated as the third-party plugin diff --git a/docs/modules/ROOT/pages/scalalib/intro.adoc b/docs/modules/ROOT/pages/scalalib/intro.adoc index 21db19866b6..d9218b93c1d 100644 --- a/docs/modules/ROOT/pages/scalalib/intro.adoc +++ b/docs/modules/ROOT/pages/scalalib/intro.adoc @@ -31,4 +31,8 @@ include::partial$example/scalalib/basic/4-compat-modules.adoc[] include::partial$example/scalalib/basic/6-realistic.adoc[] +== Building Native Image with Graal VM + +include::partial$example/scalalib/basic/7-native-image.adoc[] + diff --git a/example/javalib/basic/7-native-image/build.mill b/example/javalib/basic/7-native-image/build.mill new file mode 100644 index 00000000000..252c097b388 --- /dev/null +++ b/example/javalib/basic/7-native-image/build.mill @@ -0,0 +1,56 @@ +//// SNIPPET:BUILD +package build +import mill._, javalib._ +import mill.define.ModuleRef + +import scala.util.Properties + +object foo extends JavaModule { + + def nativeImage: T[PathRef] = Task { + val dest = T.dest + + val program = zincWorker().javaHome() match { + case None => + throw new RuntimeException("zincWorker javaHome not found") + case Some(home) => + (home.path / "bin/native-image").toString + } + val classPath = runClasspath().iterator + .map(_.path) + .mkString(java.io.File.pathSeparator) + val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") + + val command = Seq( + program, + "--class-path", + classPath, + finalMainClass(), + executableName + ) + + os.proc(command).call(cwd = dest) + + PathRef(dest / executableName) + } + + def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + + object ZincWorkerModuleGraalVm extends ZincWorkerModule { + def jvmId = "graalvm-community:23.0.1" + } +} + +// This example demonstrates how to build a native image for a Java application using https://www.graalvm.org/[Graal VM]. +// +// - The `native-image` program is downloaded with a custom Java home. +// +// - The application main class is auto detected with `finalMainClass`. + +/** Usage + +> ./mill foo.nativeImage + +> ./out/foo/nativeImage.dest/HelloWorld +Hello, World! +*/ diff --git a/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java b/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java new file mode 100644 index 00000000000..a73a5ab4361 --- /dev/null +++ b/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java @@ -0,0 +1,8 @@ +package foo; + +public class HelloWorld { + + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} diff --git a/example/kotlinlib/basic/7-native-image/build.mill b/example/kotlinlib/basic/7-native-image/build.mill new file mode 100644 index 00000000000..f4b1725bbab --- /dev/null +++ b/example/kotlinlib/basic/7-native-image/build.mill @@ -0,0 +1,59 @@ +//// SNIPPET:BUILD +package build +import mill._, kotlinlib._ +import mill.define.ModuleRef +import mill.javalib.ZincWorkerModule + +import scala.util.Properties + +object foo extends KotlinModule { + + def kotlinVersion = "1.9.24" + + def nativeImage: T[PathRef] = Task { + val dest = T.dest + + val program = zincWorker().javaHome() match { + case None => + throw new RuntimeException("zincWorker javaHome not found") + case Some(home) => + (home.path / "bin/native-image").toString + } + val classPath = runClasspath().iterator + .map(_.path) + .mkString(java.io.File.pathSeparator) + val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") + + val command = Seq( + program, + "--class-path", + classPath, + finalMainClass(), + executableName + ) + + os.proc(command).call(cwd = dest) + + PathRef(dest / executableName) + } + + def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + + object ZincWorkerModuleGraalVm extends ZincWorkerModule { + def jvmId = "graalvm-community:23.0.1" + } +} + +// This example demonstrates how to build a native image for a Kotlin application using https://www.graalvm.org/[Graal VM]. +// +// - The `native-image` program is downloaded with a custom Java home. +// +// - The application main class is auto detected with `finalMainClass`. + +/** Usage + +> ./mill foo.nativeImage + +> ./out/foo/nativeImage.dest/HelloWorld +Hello, World! +*/ diff --git a/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt b/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt new file mode 100644 index 00000000000..c7cf5472b77 --- /dev/null +++ b/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt @@ -0,0 +1,5 @@ +package foo + +fun main(args: Array) { + println("Hello, World!") +} \ No newline at end of file diff --git a/example/scalalib/basic/7-native-image/build.mill b/example/scalalib/basic/7-native-image/build.mill new file mode 100644 index 00000000000..f69ce39f2ea --- /dev/null +++ b/example/scalalib/basic/7-native-image/build.mill @@ -0,0 +1,58 @@ +//// SNIPPET:BUILD +package build +import mill._, scalalib._ +import mill.define.ModuleRef + +import scala.util.Properties + +object foo extends ScalaModule { + + def scalaVersion = "2.13.11" + + def nativeImage: T[PathRef] = Task { + val dest = T.dest + + val program = zincWorker().javaHome() match { + case None => + throw new RuntimeException("zincWorker javaHome not found") + case Some(home) => + (home.path / "bin/native-image").toString + } + val classPath = runClasspath().iterator + .map(_.path) + .mkString(java.io.File.pathSeparator) + val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") + + val command = Seq( + program, + "--class-path", + classPath, + finalMainClass(), + executableName + ) + + os.proc(command).call(cwd = dest) + + PathRef(dest / executableName) + } + + def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + + object ZincWorkerModuleGraalVm extends ZincWorkerModule { + def jvmId = "graalvm-community:23.0.1" + } +} + +// This example demonstrates how to build a native image for a Scala application using https://www.graalvm.org/[Graal VM]. +// +// - The `native-image` program is downloaded with a custom Java home. +// +// - The application main class is auto detected with `finalMainClass`. + +/** Usage + +> ./mill foo.nativeImage + +> ./out/foo/nativeImage.dest/HelloWorld +Hello, World! +*/ diff --git a/example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala b/example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala new file mode 100644 index 00000000000..e8ab75ee6b3 --- /dev/null +++ b/example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala @@ -0,0 +1,7 @@ +package foo + +object HelloWorld { + + def main(args: Array[String]): Unit = + println("Hello, World!") +} From d6746ddde6fb09d9262c476f6dbca00128142b50 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Fri, 29 Nov 2024 00:40:15 +0530 Subject: [PATCH 03/61] Fix format --- .../basic/7-native-image/foo/src/foo/HelloWorld.java | 6 +++--- .../basic/7-native-image/foo/src/foo/HelloWorld.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java b/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java index a73a5ab4361..699ebbd8043 100644 --- a/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java +++ b/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java @@ -2,7 +2,7 @@ public class HelloWorld { - public static void main(String[] args) { - System.out.println("Hello, World!"); - } + public static void main(String[] args) { + System.out.println("Hello, World!"); + } } diff --git a/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt b/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt index c7cf5472b77..972307cd6d3 100644 --- a/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt +++ b/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt @@ -2,4 +2,4 @@ package foo fun main(args: Array) { println("Hello, World!") -} \ No newline at end of file +} From 1205f80d106f9ffc1f20540cf9a93fa5938d0150 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Fri, 29 Nov 2024 00:55:13 +0530 Subject: [PATCH 04/61] Fix format --- .../client/src/mill/runner/client/MillProcessLauncher.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runner/client/src/mill/runner/client/MillProcessLauncher.java b/runner/client/src/mill/runner/client/MillProcessLauncher.java index 9f5ef6bde2a..4c63ce1f90b 100644 --- a/runner/client/src/mill/runner/client/MillProcessLauncher.java +++ b/runner/client/src/mill/runner/client/MillProcessLauncher.java @@ -147,7 +147,11 @@ static String[] millClasspath() throws Exception { if (selfJars == null || selfJars.trim().isEmpty()) { // Assuming native assembly run - selfJars = MillProcessLauncher.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + selfJars = MillProcessLauncher.class + .getProtectionDomain() + .getCodeSource() + .getLocation() + .getPath(); } if (selfJars == null || selfJars.trim().isEmpty()) { From d7b275109da04959494e269135aa54f6092a0c35 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Fri, 29 Nov 2024 02:34:28 +0530 Subject: [PATCH 05/61] Handle native-image file extension --- build.mill | 2 +- dist/package.mill | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/build.mill b/build.mill index e313cbe4de8..98fe8e327d6 100644 --- a/build.mill +++ b/build.mill @@ -43,7 +43,7 @@ object Settings { val mimaBaseVersions: Seq[String] = 0.to(13).map("0.11." + _) ++ Seq("0.12.0", "0.12.1", "0.12.2", "0.12.3") - val graalVmJvmId = "graalvm-community:23.0.1" + val graalvmJvmId = "graalvm-community:23.0.1" } object Deps { diff --git a/dist/package.mill b/dist/package.mill index a57ca22c35f..bf80e45b72c 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -372,22 +372,18 @@ object `package` extends RootModule with build.MillPublishJavaModule { def nativeImage: T[PathRef] = Task { val dest = T.dest - val program = zincWorker().javaHome() match { - case None => - throw new RuntimeException("zincWorker javaHome not found") - case Some(home) => - (home.path / "bin/native-image").toString - } val classPath = runClasspath().iterator .map(_.path) .mkString(java.io.File.pathSeparator) val executableName = "mill-native" + (if (Properties.isWin) ".exe" else "") val command = - Seq(program) ++ - Seq("--class-path", classPath) ++ - nativeImageOptions() ++ - Seq(finalMainClass(), executableName) + Seq.newBuilder[String] + .+=(nativeImageCli().path.toString) + .++=(Seq("--class-path", classPath)) + .++=(nativeImageOptions()) + .++=(Seq(finalMainClass(), executableName)) + .result() T.log.info(s"building native image $executableName") os.proc(command).call(cwd = dest) @@ -395,6 +391,18 @@ object `package` extends RootModule with build.MillPublishJavaModule { PathRef(dest / executableName) } + def nativeImageCli: T[PathRef] = Task { + zincWorker().javaHome() match { + case None => + throw new RuntimeException("ZincWorkerModule.javaHome not found") + case Some(home) => + val ext = if (Properties.isWin) ".cmd" else "" + val path = (home.path / "bin" / s"native-image$ext") + if (os.exists(path)) PathRef(path) + else throw new RuntimeException("native-image not found at $path") + } + } + def nativeImageOptions: T[Seq[String]] = Task { val (millArgs, otherArgs) = forkArgs().partition(arg => arg.startsWith("-DMILL") && !arg.startsWith("-DMILL_VERSION")) @@ -413,9 +421,9 @@ object `package` extends RootModule with build.MillPublishJavaModule { .result() } - def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + def zincWorker = ModuleRef(ZincWorkerGraalvm) - object ZincWorkerModuleGraalVm extends ZincWorkerModule { - def jvmId = build.Settings.graalVmJvmId + object ZincWorkerGraalvm extends ZincWorkerModule { + def jvmId = build.Settings.graalvmJvmId } } From 036088030f532ae946caf1062185658ec61d8605 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Fri, 29 Nov 2024 05:15:55 +0530 Subject: [PATCH 06/61] Added NativeImageModule --- dist/package.mill | 22 ++++-- .../native-image/reachability-metadata.json | 5 ++ .../javalib/basic/7-native-image/build.mill | 41 ++-------- .../kotlinlib/basic/7-native-image/build.mill | 42 ++-------- .../scalalib/basic/7-native-image/build.mill | 39 ++-------- kotlinlib/src/mill/kotlinlib/package.scala | 5 ++ scalalib/src/mill/javalib/package.scala | 2 + .../src/mill/scalalib/NativeImageModule.scala | 77 +++++++++++++++++++ 8 files changed, 123 insertions(+), 110 deletions(-) create mode 100644 scalalib/src/mill/scalalib/NativeImageModule.scala diff --git a/dist/package.mill b/dist/package.mill index bf80e45b72c..d1b8475615e 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -6,8 +6,10 @@ import mill.api.JarManifest import de.tobiasroeser.mill.vcs.version.VcsVersion import $file.ci.upload +import java.nio.file.Paths import scala.util.{Properties, Using} +// TODO remove nativeImage* tasks and extend NativeImageModule once available object `package` extends RootModule with build.MillPublishJavaModule { /** @@ -375,7 +377,7 @@ object `package` extends RootModule with build.MillPublishJavaModule { val classPath = runClasspath().iterator .map(_.path) .mkString(java.io.File.pathSeparator) - val executableName = "mill-native" + (if (Properties.isWin) ".exe" else "") + val executableName = nativeImageExecutableName() val command = Seq.newBuilder[String] @@ -392,15 +394,20 @@ object `package` extends RootModule with build.MillPublishJavaModule { } def nativeImageCli: T[PathRef] = Task { - zincWorker().javaHome() match { + val ext = if (Properties.isWin) ".cmd" else "" + val path = zincWorker().javaHome() match { case None => - throw new RuntimeException("ZincWorkerModule.javaHome not found") + os.Path(Paths.get(s"native-image$ext").toAbsolutePath) case Some(home) => - val ext = if (Properties.isWin) ".cmd" else "" - val path = (home.path / "bin" / s"native-image$ext") - if (os.exists(path)) PathRef(path) - else throw new RuntimeException("native-image not found at $path") + home.path / "bin" / s"native-image$ext" } + if (os.exists(path)) PathRef(path) + else throw new RuntimeException(s"native-image not found at $path") + } + + def nativeImageExecutableName: T[String] = Task { + val name = finalMainClass().split('.').last + if (Properties.isWin) s"$name.exe" else name } def nativeImageOptions: T[Seq[String]] = Task { @@ -415,7 +422,6 @@ object `package` extends RootModule with build.MillPublishJavaModule { os.write(vmOptionsFile, millOptionsContent) Seq.newBuilder[String] .+=("--no-fallback") - .+=("-H:IncludeResources=logback.xml") .+=(s"-DMILL_OPTIONS_PATH=$vmOptionsFile") .++=(otherArgs) .result() diff --git a/dist/resources/META-INF/native-image/reachability-metadata.json b/dist/resources/META-INF/native-image/reachability-metadata.json index 8de767df2af..945749cdad1 100644 --- a/dist/resources/META-INF/native-image/reachability-metadata.json +++ b/dist/resources/META-INF/native-image/reachability-metadata.json @@ -6,5 +6,10 @@ { "type": "mill.runner.MillServerMain" } + ], + "resources": [ + { + "glob": "logback.xml" + } ] } \ No newline at end of file diff --git a/example/javalib/basic/7-native-image/build.mill b/example/javalib/basic/7-native-image/build.mill index 252c097b388..ebc50cc5f5b 100644 --- a/example/javalib/basic/7-native-image/build.mill +++ b/example/javalib/basic/7-native-image/build.mill @@ -3,49 +3,22 @@ package build import mill._, javalib._ import mill.define.ModuleRef -import scala.util.Properties - -object foo extends JavaModule { - - def nativeImage: T[PathRef] = Task { - val dest = T.dest - - val program = zincWorker().javaHome() match { - case None => - throw new RuntimeException("zincWorker javaHome not found") - case Some(home) => - (home.path / "bin/native-image").toString - } - val classPath = runClasspath().iterator - .map(_.path) - .mkString(java.io.File.pathSeparator) - val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") - - val command = Seq( - program, - "--class-path", - classPath, - finalMainClass(), - executableName - ) - - os.proc(command).call(cwd = dest) - - PathRef(dest / executableName) - } +object foo extends JavaModule with NativeImageModule { + + def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + def zincWorker = ModuleRef(ZincWorkerGraalvm) - object ZincWorkerModuleGraalVm extends ZincWorkerModule { + object ZincWorkerGraalvm extends ZincWorkerModule { def jvmId = "graalvm-community:23.0.1" } } // This example demonstrates how to build a native image for a Java application using https://www.graalvm.org/[Graal VM]. // -// - The `native-image` program is downloaded with a custom Java home. +// - The `native-image` CLI is downloaded with a custom Java home. // -// - The application main class is auto detected with `finalMainClass`. +// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. /** Usage diff --git a/example/kotlinlib/basic/7-native-image/build.mill b/example/kotlinlib/basic/7-native-image/build.mill index f4b1725bbab..476d2460781 100644 --- a/example/kotlinlib/basic/7-native-image/build.mill +++ b/example/kotlinlib/basic/7-native-image/build.mill @@ -2,58 +2,30 @@ package build import mill._, kotlinlib._ import mill.define.ModuleRef -import mill.javalib.ZincWorkerModule -import scala.util.Properties - -object foo extends KotlinModule { +object foo extends KotlinModule with NativeImageModule { def kotlinVersion = "1.9.24" - def nativeImage: T[PathRef] = Task { - val dest = T.dest - - val program = zincWorker().javaHome() match { - case None => - throw new RuntimeException("zincWorker javaHome not found") - case Some(home) => - (home.path / "bin/native-image").toString - } - val classPath = runClasspath().iterator - .map(_.path) - .mkString(java.io.File.pathSeparator) - val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") - - val command = Seq( - program, - "--class-path", - classPath, - finalMainClass(), - executableName - ) - - os.proc(command).call(cwd = dest) - - PathRef(dest / executableName) - } + def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + def zincWorker = ModuleRef(ZincWorkerGraalvm) - object ZincWorkerModuleGraalVm extends ZincWorkerModule { + object ZincWorkerGraalvm extends ZincWorkerModule { def jvmId = "graalvm-community:23.0.1" } } // This example demonstrates how to build a native image for a Kotlin application using https://www.graalvm.org/[Graal VM]. // -// - The `native-image` program is downloaded with a custom Java home. +// - The `native-image` CLI is downloaded with a custom Java home. // -// - The application main class is auto detected with `finalMainClass`. +// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. /** Usage > ./mill foo.nativeImage -> ./out/foo/nativeImage.dest/HelloWorld +> ./out/foo/nativeImage.dest/HelloWorldKt Hello, World! */ diff --git a/example/scalalib/basic/7-native-image/build.mill b/example/scalalib/basic/7-native-image/build.mill index f69ce39f2ea..8923b5644e1 100644 --- a/example/scalalib/basic/7-native-image/build.mill +++ b/example/scalalib/basic/7-native-image/build.mill @@ -3,51 +3,24 @@ package build import mill._, scalalib._ import mill.define.ModuleRef -import scala.util.Properties - -object foo extends ScalaModule { +object foo extends ScalaModule with NativeImageModule { def scalaVersion = "2.13.11" - def nativeImage: T[PathRef] = Task { - val dest = T.dest - - val program = zincWorker().javaHome() match { - case None => - throw new RuntimeException("zincWorker javaHome not found") - case Some(home) => - (home.path / "bin/native-image").toString - } - val classPath = runClasspath().iterator - .map(_.path) - .mkString(java.io.File.pathSeparator) - val executableName = "HelloWorld" + (if (Properties.isWin) ".exe" else "") - - val command = Seq( - program, - "--class-path", - classPath, - finalMainClass(), - executableName - ) - - os.proc(command).call(cwd = dest) - - PathRef(dest / executableName) - } + def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerModuleGraalVm) + def zincWorker = ModuleRef(ZincWorkerGraalvm) - object ZincWorkerModuleGraalVm extends ZincWorkerModule { + object ZincWorkerGraalvm extends ZincWorkerModule { def jvmId = "graalvm-community:23.0.1" } } // This example demonstrates how to build a native image for a Scala application using https://www.graalvm.org/[Graal VM]. // -// - The `native-image` program is downloaded with a custom Java home. +// - The `native-image` CLI is downloaded with a custom Java home. // -// - The application main class is auto detected with `finalMainClass`. +// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. /** Usage diff --git a/kotlinlib/src/mill/kotlinlib/package.scala b/kotlinlib/src/mill/kotlinlib/package.scala index 54548e24d70..51b0599b97e 100644 --- a/kotlinlib/src/mill/kotlinlib/package.scala +++ b/kotlinlib/src/mill/kotlinlib/package.scala @@ -18,4 +18,9 @@ package object kotlinlib { type PublishModule = mill.scalalib.PublishModule val PublishModule = mill.scalalib.PublishModule + + type NativeImageModule = mill.scalalib.NativeImageModule + + type ZincWorkerModule = mill.scalalib.ZincWorkerModule + val ZincWorkerModule = mill.scalalib.ZincWorkerModule } diff --git a/scalalib/src/mill/javalib/package.scala b/scalalib/src/mill/javalib/package.scala index 5deb76b8c75..780dec9f0a9 100644 --- a/scalalib/src/mill/javalib/package.scala +++ b/scalalib/src/mill/javalib/package.scala @@ -15,6 +15,8 @@ package object javalib extends mill.scalalib.JsonFormatters { type JavaModule = mill.scalalib.JavaModule + type NativeImageModule = mill.scalalib.NativeImageModule + val ZincWorkerModule = mill.scalalib.ZincWorkerModule type ZincWorkerModule = mill.scalalib.ZincWorkerModule diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala new file mode 100644 index 00000000000..3532f7882a3 --- /dev/null +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -0,0 +1,77 @@ +package mill.scalalib + +import mill.* + +import java.nio.file.Paths +import scala.util.Properties + +/** + * Provides a [[nativeImage task]] to generate a native binary for this JVM application. + * + * For reproducible builds, specify a custom Java home. + * {{{ + * trait AppModule extends NativeImageModule { + * def zincWorker = ModuleRef(ZincWorkerGraalvm) + * + * object ZincWorkerGraalvm extends ZincWorkerModule { + * def jvmId = "graalvm-community:23.0.1" + * } + * } + * }}} + */ +trait NativeImageModule extends RunModule { + + /** + * Generates a native binary for [[finalMainClass]] using [[nativeImageCli]]. + */ + def nativeImage: T[PathRef] = Task { + val dest = T.dest + + val classPath = runClasspath().iterator + .map(_.path) + .mkString(java.io.File.pathSeparator) + val executableName = nativeImageExecutableName() + + val command = + Seq.newBuilder[String] + .+=(nativeImageCli().path.toString) + .++=(Seq("--class-path", classPath)) + .++=(nativeImageOptions()) + .++=(Seq(finalMainClass(), executableName)) + .result() + + T.log.info(s"building native image $executableName") + os.proc(command).call(cwd = dest) + + PathRef(dest / executableName) + } + + /** + * Path to [[https://www.graalvm.org/latest/reference-manual/native-image/ `native-image`]] CLI. + * Defaults to a value relative to [[ZincWorkerModule.javaHome]] or to the installed `native-image` path. + */ + def nativeImageCli: T[PathRef] = Task { + val ext = if (Properties.isWin) ".cmd" else "" + val path = zincWorker().javaHome() match { + case None => + os.Path(Paths.get(s"native-image$ext").toAbsolutePath) + case Some(home) => + home.path / "bin" / s"native-image$ext" + } + if (os.exists(path)) PathRef(path) + else throw new RuntimeException(s"native-image not found at $path") + } + + /** + * The name of the generated native binary. + */ + def nativeImageExecutableName: T[String] = Task { + val name = finalMainClass().split('.').last + if (Properties.isWin) s"$name.exe" else name + } + + /** + * Additional options for [[nativeImageCli]]. + */ + def nativeImageOptions: T[Seq[String]] = Seq.empty[String] +} From 2d36e26c2b2da372168099d7ea7759b3d4879a2a Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Sat, 30 Nov 2024 10:15:16 +0530 Subject: [PATCH 07/61] Use GRAALVM_HOME env var --- scalalib/src/mill/scalalib/NativeImageModule.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index 3532f7882a3..d679ba9ad12 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -48,15 +48,18 @@ trait NativeImageModule extends RunModule { /** * Path to [[https://www.graalvm.org/latest/reference-manual/native-image/ `native-image`]] CLI. - * Defaults to a value relative to [[ZincWorkerModule.javaHome]] or to the installed `native-image` path. + * Defaults to `bin/native-image` relative to [[ZincWorkerModule.javaHome]] or `GRAALVM_HOME` environment variable. */ def nativeImageCli: T[PathRef] = Task { val ext = if (Properties.isWin) ".cmd" else "" - val path = zincWorker().javaHome() match { + val path = zincWorker().javaHome() + .map(_.path) + .orElse(sys.env.get("GRAALVM_HOME").map(os.Path(_))) match { case None => + // assume native-image is installed os.Path(Paths.get(s"native-image$ext").toAbsolutePath) case Some(home) => - home.path / "bin" / s"native-image$ext" + home / "bin" / s"native-image$ext" } if (os.exists(path)) PathRef(path) else throw new RuntimeException(s"native-image not found at $path") From f5da9689bedf98cbb69eb0439783d2b845971571 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Sat, 30 Nov 2024 13:56:16 +0530 Subject: [PATCH 08/61] Setup build tools for native-image on Windows --- .github/workflows/run-mill-action.yml | 7 +++++++ .github/workflows/run-tests.yml | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index f77fd86ad93..c0002a3776f 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -30,6 +30,10 @@ on: install-android-sdk: default: false type: boolean + setup-msvc: + default: false + type: boolean + description: 'sets up Windows environment for compiling C/C++ code' jobs: run: @@ -56,6 +60,9 @@ jobs: - uses: coursier/cache-action@v6 + - uses: ilammy/msvc-dev-cmd@v1 + if: inputs.setup-msvc && startsWith(inputs.os, 'windows') + - uses: actions/setup-java@v4 with: java-version: ${{ inputs.java-version }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 12174111543..0119341d1e2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -135,20 +135,26 @@ jobs: # the whole suite can take hours on windows v.s. half an hour on linux - java-version: '11' millargs: '"{main,scalalib,bsp}.__.testCached"' + setup-msvc: false - java-version: '11' millargs: '"example.scalalib.basic.__.fork.testCached"' + setup-msvc: true # required by Graal VM native-image - java-version: 17 millargs: "'integration.{feature,failure}[_].fork.testCached'" + setup-msvc: false - java-version: '11' millargs: "'integration.invalidation[_].server.testCached'" + setup-msvc: false - java-version: '11' millargs: "contrib.__.testCached" + setup-msvc: false uses: ./.github/workflows/run-mill-action.yml with: os: windows-latest java-version: ${{ matrix.java-version }} millargs: ${{ matrix.millargs }} + setup-msvc: ${{ matrix.setup-msvc }} itest: needs: build-linux From 5f6926c764384643b63772ba78263ceccb30e1d4 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Mon, 2 Dec 2024 02:59:28 +0530 Subject: [PATCH 09/61] Refactor --- .github/workflows/run-mill-action.yml | 7 -- .github/workflows/run-tests.yml | 6 -- dist/package.mill | 99 ++++++------------- .../javalib/basic/7-native-image/build.mill | 13 +-- .../foo/src/foo/{HelloWorld.java => App.java} | 2 +- .../kotlinlib/basic/7-native-image/build.mill | 17 ++-- .../foo/src/foo/{HelloWorld.kt => App.kt} | 0 .../scalalib/basic/7-native-image/build.mill | 17 ++-- .../src/foo/{HelloWorld.scala => App.scala} | 2 +- .../runner/client/MillNoServerLauncher.java | 3 +- .../src/mill/scalalib/NativeImageModule.scala | 89 +++++++++-------- 11 files changed, 104 insertions(+), 151 deletions(-) rename example/javalib/basic/7-native-image/foo/src/foo/{HelloWorld.java => App.java} (80%) rename example/kotlinlib/basic/7-native-image/foo/src/foo/{HelloWorld.kt => App.kt} (100%) rename example/scalalib/basic/7-native-image/foo/src/foo/{HelloWorld.scala => App.scala} (80%) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index c0002a3776f..f77fd86ad93 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -30,10 +30,6 @@ on: install-android-sdk: default: false type: boolean - setup-msvc: - default: false - type: boolean - description: 'sets up Windows environment for compiling C/C++ code' jobs: run: @@ -60,9 +56,6 @@ jobs: - uses: coursier/cache-action@v6 - - uses: ilammy/msvc-dev-cmd@v1 - if: inputs.setup-msvc && startsWith(inputs.os, 'windows') - - uses: actions/setup-java@v4 with: java-version: ${{ inputs.java-version }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0119341d1e2..12174111543 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -135,26 +135,20 @@ jobs: # the whole suite can take hours on windows v.s. half an hour on linux - java-version: '11' millargs: '"{main,scalalib,bsp}.__.testCached"' - setup-msvc: false - java-version: '11' millargs: '"example.scalalib.basic.__.fork.testCached"' - setup-msvc: true # required by Graal VM native-image - java-version: 17 millargs: "'integration.{feature,failure}[_].fork.testCached'" - setup-msvc: false - java-version: '11' millargs: "'integration.invalidation[_].server.testCached'" - setup-msvc: false - java-version: '11' millargs: "contrib.__.testCached" - setup-msvc: false uses: ./.github/workflows/run-mill-action.yml with: os: windows-latest java-version: ${{ matrix.java-version }} millargs: ${{ matrix.millargs }} - setup-msvc: ${{ matrix.setup-msvc }} itest: needs: build-linux diff --git a/dist/package.mill b/dist/package.mill index d1b8475615e..cb9a2cf30e9 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -6,10 +6,9 @@ import mill.api.JarManifest import de.tobiasroeser.mill.vcs.version.VcsVersion import $file.ci.upload -import java.nio.file.Paths import scala.util.{Properties, Using} -// TODO remove nativeImage* tasks and extend NativeImageModule once available +// TODO extend NativeImageModule once available object `package` extends RootModule with build.MillPublishJavaModule { /** @@ -348,83 +347,49 @@ object `package` extends RootModule with build.MillPublishJavaModule { } } - def mainClass = Some("mill.runner.client.MillClientMain") - - def native: T[PathRef] = Task { - val executable = Task.dest / "mill" + def nativeImage(args: String*): Command[PathRef] = Task.Command { + val dest = T.dest + val executableName = if (Properties.isWin) "mill.exe" else "mill" + val executable = Task.dest / executableName Task.traverse(allPublishModules)(m => m.publishLocalCached)() + val assembly = super.assembly().path + + val command = Seq.newBuilder[String] + .+=(nativeImageTool().path.toString) + .++=(Seq("-cp", assembly.toString)) + // Workaround for Zinc/JNA bug + // https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130 + .+=("-Djna.nosys=true") + .+=("--no-fallback") + .++=(args) + .+=("mill.runner.client.MillClientMain") + .+=(executableName) + .result() + os.proc(command).call(cwd = dest, stdout = os.Inherit) - Using(os.write.outputStream( - executable, - if (Properties.isWin) null else "rwxrwxrwx", - createFolders = true) - ) { out => - // concatenate native image and assembly as prescribed in: - // https://github.com/com-lihaoyi/mill/issues/4007#issuecomment-2495933167 - out.write(os.read.bytes(nativeImage().path)) + // concatenate executable and assembly as prescribed in: + // https://github.com/com-lihaoyi/mill/issues/4007#issuecomment-2495933167 + Using(os.write.append.outputStream(executable)) { out => out.write(System.lineSeparator.getBytes) - out.write(os.read.bytes(super.assembly().path)) + out.write(os.read.bytes(assembly)) out.flush() } PathRef(executable) } - def nativeImage: T[PathRef] = Task { - val dest = T.dest - - val classPath = runClasspath().iterator - .map(_.path) - .mkString(java.io.File.pathSeparator) - val executableName = nativeImageExecutableName() - - val command = - Seq.newBuilder[String] - .+=(nativeImageCli().path.toString) - .++=(Seq("--class-path", classPath)) - .++=(nativeImageOptions()) - .++=(Seq(finalMainClass(), executableName)) - .result() - - T.log.info(s"building native image $executableName") - os.proc(command).call(cwd = dest) - - PathRef(dest / executableName) - } - - def nativeImageCli: T[PathRef] = Task { - val ext = if (Properties.isWin) ".cmd" else "" - val path = zincWorker().javaHome() match { - case None => - os.Path(Paths.get(s"native-image$ext").toAbsolutePath) + def nativeImageTool: T[PathRef] = Task { + zincWorker().javaHome().map(_.path) + .orElse(sys.env.get("GRAALVM_HOME").map(os.Path(_))) match { case Some(home) => - home.path / "bin" / s"native-image$ext" + val tool = if (Properties.isWin) "native-image.cmd" else "native-image" + val path = home / "bin" / tool + if (os.exists(path)) PathRef(path) + else throw new RuntimeException(s"$path not found") + case None => + throw new RuntimeException("ZincWorkerModule.javaHome/GRAALVM_HOME not defined") } - if (os.exists(path)) PathRef(path) - else throw new RuntimeException(s"native-image not found at $path") - } - - def nativeImageExecutableName: T[String] = Task { - val name = finalMainClass().split('.').last - if (Properties.isWin) s"$name.exe" else name - } - - def nativeImageOptions: T[Seq[String]] = 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) - Seq.newBuilder[String] - .+=("--no-fallback") - .+=(s"-DMILL_OPTIONS_PATH=$vmOptionsFile") - .++=(otherArgs) - .result() } def zincWorker = ModuleRef(ZincWorkerGraalvm) diff --git a/example/javalib/basic/7-native-image/build.mill b/example/javalib/basic/7-native-image/build.mill index ebc50cc5f5b..824669f5784 100644 --- a/example/javalib/basic/7-native-image/build.mill +++ b/example/javalib/basic/7-native-image/build.mill @@ -5,8 +5,6 @@ import mill.define.ModuleRef object foo extends JavaModule with NativeImageModule { - def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { @@ -14,16 +12,15 @@ object foo extends JavaModule with NativeImageModule { } } -// This example demonstrates how to build a native image for a Java application using https://www.graalvm.org/[Graal VM]. -// -// - The `native-image` CLI is downloaded with a custom Java home. -// -// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. +// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. +// NOTE: For build portability, it is recommended to use a custom JDK. /** Usage > ./mill foo.nativeImage +GraalVM Native Image: Generating...App... +Finished generating...App... -> ./out/foo/nativeImage.dest/HelloWorld +> ./out/foo/nativeImage.dest/App Hello, World! */ diff --git a/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java b/example/javalib/basic/7-native-image/foo/src/foo/App.java similarity index 80% rename from example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java rename to example/javalib/basic/7-native-image/foo/src/foo/App.java index 699ebbd8043..e7b50c8f537 100644 --- a/example/javalib/basic/7-native-image/foo/src/foo/HelloWorld.java +++ b/example/javalib/basic/7-native-image/foo/src/foo/App.java @@ -1,6 +1,6 @@ package foo; -public class HelloWorld { +public class App { public static void main(String[] args) { System.out.println("Hello, World!"); diff --git a/example/kotlinlib/basic/7-native-image/build.mill b/example/kotlinlib/basic/7-native-image/build.mill index 476d2460781..9cc8efc12ae 100644 --- a/example/kotlinlib/basic/7-native-image/build.mill +++ b/example/kotlinlib/basic/7-native-image/build.mill @@ -5,27 +5,24 @@ import mill.define.ModuleRef object foo extends KotlinModule with NativeImageModule { - def kotlinVersion = "1.9.24" - - def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { def jvmId = "graalvm-community:23.0.1" } + + def kotlinVersion = "1.9.24" } -// This example demonstrates how to build a native image for a Kotlin application using https://www.graalvm.org/[Graal VM]. -// -// - The `native-image` CLI is downloaded with a custom Java home. -// -// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. +// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. +// NOTE: For build portability, it is recommended to use a custom JDK. /** Usage > ./mill foo.nativeImage +GraalVM Native Image: Generating...AppKt... +Finished generating...AppKt... -> ./out/foo/nativeImage.dest/HelloWorldKt +> ./out/foo/nativeImage.dest/AppKt Hello, World! */ diff --git a/example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt b/example/kotlinlib/basic/7-native-image/foo/src/foo/App.kt similarity index 100% rename from example/kotlinlib/basic/7-native-image/foo/src/foo/HelloWorld.kt rename to example/kotlinlib/basic/7-native-image/foo/src/foo/App.kt diff --git a/example/scalalib/basic/7-native-image/build.mill b/example/scalalib/basic/7-native-image/build.mill index 8923b5644e1..4b00c457e4e 100644 --- a/example/scalalib/basic/7-native-image/build.mill +++ b/example/scalalib/basic/7-native-image/build.mill @@ -5,27 +5,24 @@ import mill.define.ModuleRef object foo extends ScalaModule with NativeImageModule { - def scalaVersion = "2.13.11" - - def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { def jvmId = "graalvm-community:23.0.1" } + + def scalaVersion = "2.13.11" } -// This example demonstrates how to build a native image for a Scala application using https://www.graalvm.org/[Graal VM]. -// -// - The `native-image` CLI is downloaded with a custom Java home. -// -// - The main class, `foo.HelloWorld` is auto detected by `NativeImageModule` using `finalMainClass`. +// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. +// NOTE: For build portability, it is recommended to use a custom JDK. /** Usage > ./mill foo.nativeImage +GraalVM Native Image: Generating...App... +Finished generating...App... -> ./out/foo/nativeImage.dest/HelloWorld +> ./out/foo/nativeImage.dest/App Hello, World! */ diff --git a/example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala b/example/scalalib/basic/7-native-image/foo/src/foo/App.scala similarity index 80% rename from example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala rename to example/scalalib/basic/7-native-image/foo/src/foo/App.scala index e8ab75ee6b3..7faaed3b53e 100644 --- a/example/scalalib/basic/7-native-image/foo/src/foo/HelloWorld.scala +++ b/example/scalalib/basic/7-native-image/foo/src/foo/App.scala @@ -1,6 +1,6 @@ package foo -object HelloWorld { +object App { def main(args: Array[String]): Unit = println("Hello, World!") diff --git a/runner/client/src/mill/runner/client/MillNoServerLauncher.java b/runner/client/src/mill/runner/client/MillNoServerLauncher.java index 5fb56186258..21c9000b47a 100644 --- a/runner/client/src/mill/runner/client/MillNoServerLauncher.java +++ b/runner/client/src/mill/runner/client/MillNoServerLauncher.java @@ -27,8 +27,7 @@ public static LoadResult load() { long startTime = System.currentTimeMillis(); Optional millMainMethod = Optional.empty(); try { - Class millMainClass = - MillNoServerLauncher.class.getClassLoader().loadClass("mill.runner.MillMain"); + Class millMainClass = Class.forName("mill.runner.MillMain"); Method mainMethod = millMainClass.getMethod("main", String[].class); millMainMethod = Optional.of(mainMethod); } catch (ClassNotFoundException | NoSuchMethodException e) { diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index d679ba9ad12..fff82d4dd57 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -2,13 +2,12 @@ package mill.scalalib import mill.* -import java.nio.file.Paths import scala.util.Properties /** - * Provides a [[nativeImage task]] to generate a native binary for this JVM application. + * Provides a [[NativeImageModule.nativeImage task]] to build a native executable using [[https://www.graalvm.org/ Graal VM]]. * - * For reproducible builds, specify a custom Java home. + * It is recommended to specify a custom JDK that includes the `native-image` Tool. * {{{ * trait AppModule extends NativeImageModule { * def zincWorker = ModuleRef(ZincWorkerGraalvm) @@ -19,54 +18,43 @@ import scala.util.Properties * } * }}} */ -trait NativeImageModule extends RunModule { +@mill.api.experimental +trait NativeImageModule extends RunModule with WithZincWorker { /** - * Generates a native binary for [[finalMainClass]] using [[nativeImageCli]]. + * [[https://www.graalvm.org/latest/reference-manual/native-image/#from-a-class Builds a native executable]] for this + * module with [[finalMainClass]] as the application entry point. + * + * @param args Additional options for the `native-image` Tool. Use for + * - passing debug options + * - passing target specific options */ - def nativeImage: T[PathRef] = Task { + def nativeImage(args: String*): Command[PathRef] = Task.Command { val dest = T.dest - - val classPath = runClasspath().iterator - .map(_.path) - .mkString(java.io.File.pathSeparator) val executableName = nativeImageExecutableName() - - val command = - Seq.newBuilder[String] - .+=(nativeImageCli().path.toString) - .++=(Seq("--class-path", classPath)) - .++=(nativeImageOptions()) - .++=(Seq(finalMainClass(), executableName)) - .result() - - T.log.info(s"building native image $executableName") - os.proc(command).call(cwd = dest) - + val command = Seq.newBuilder[String] + .+=(nativeImageTool().path.toString) + .++=(nativeImageOptions()) + .++=(args) + .+=("-cp") + .+=(nativeImageClasspath().iterator.map(_.path).mkString(java.io.File.pathSeparator)) + .+=(finalMainClass()) + .+=(executableName) + .result() + os.proc(command).call(cwd = dest, stdout = os.Inherit) PathRef(dest / executableName) } /** - * Path to [[https://www.graalvm.org/latest/reference-manual/native-image/ `native-image`]] CLI. - * Defaults to `bin/native-image` relative to [[ZincWorkerModule.javaHome]] or `GRAALVM_HOME` environment variable. + * The classpath to use to generate the native image. Defaults to [[runClasspath]]. */ - def nativeImageCli: T[PathRef] = Task { - val ext = if (Properties.isWin) ".cmd" else "" - val path = zincWorker().javaHome() - .map(_.path) - .orElse(sys.env.get("GRAALVM_HOME").map(os.Path(_))) match { - case None => - // assume native-image is installed - os.Path(Paths.get(s"native-image$ext").toAbsolutePath) - case Some(home) => - home / "bin" / s"native-image$ext" - } - if (os.exists(path)) PathRef(path) - else throw new RuntimeException(s"native-image not found at $path") + def nativeImageClasspath: T[Seq[PathRef]] = Task { + runClasspath() } /** - * The name of the generated native binary. + * The name of the generated executable. + * Defaults to name of [[finalMainClass]] (with `exe` extension, on Windows). */ def nativeImageExecutableName: T[String] = Task { val name = finalMainClass().split('.').last @@ -74,7 +62,30 @@ trait NativeImageModule extends RunModule { } /** - * Additional options for [[nativeImageCli]]. + * Additional options for the `native-image` Tool. + * + * @note It is recommended to restrict this list to options that can be shared across targets. */ def nativeImageOptions: T[Seq[String]] = Seq.empty[String] + + /** + * Path to the [[https://www.graalvm.org/latest/reference-manual/native-image/ `native-image` Tool]]. + * Defaults to a path relative to + * - [[ZincWorkerModule.javaHome]], if defined + * - environment variable `GRAALVM_HOME`, if defined + * + * @note The task fails if the `native-image` Tool is not found. + */ + def nativeImageTool: T[PathRef] = Task { + zincWorker().javaHome().map(_.path) + .orElse(sys.env.get("GRAALVM_HOME").map(os.Path(_))) match { + case Some(home) => + val tool = if (Properties.isWin) "native-image.cmd" else "native-image" + val path = home / "bin" / tool + if (os.exists(path)) PathRef(path) + else throw new RuntimeException(s"$path not found") + case None => + throw new RuntimeException("ZincWorkerModule.javaHome/GRAALVM_HOME not defined") + } + } } From a88c5c10b422d7fa05de2563f6a21e09b51978e3 Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Mon, 2 Dec 2024 03:07:10 +0530 Subject: [PATCH 10/61] Fix unidoc error --- scalalib/src/mill/scalalib/NativeImageModule.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index fff82d4dd57..7ea1554c79a 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -1,6 +1,6 @@ package mill.scalalib -import mill.* +import mill._ import scala.util.Properties From a71dacdb3ba29f70482c4c06466ec8c841cf412f Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Mon, 2 Dec 2024 20:37:10 +0530 Subject: [PATCH 11/61] Try to fix Windows CI error with setup-graalvm --- .github/workflows/run-mill-action.yml | 10 ++++++++++ .github/workflows/run-tests.yml | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index f77fd86ad93..5e3ecf44518 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -12,6 +12,9 @@ on: java-version: required: true type: string + use-graalvm: + default: false + type: boolean os: default: 'ubuntu-latest' type: string @@ -60,6 +63,13 @@ jobs: with: java-version: ${{ inputs.java-version }} distribution: temurin + if: !inputs.use-graalvm + + - uses: graalvm/setup-graalvm@v1 + with: + java-version: ${{ inputs.java-version }} + distribution: graalvm-community + if: inputs.use-graalvm - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 12174111543..d4f4b2aaf59 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -134,20 +134,27 @@ jobs: # just run a subset of examples/ on Windows, because for some reason running # the whole suite can take hours on windows v.s. half an hour on linux - java-version: '11' + use-graalvm: false millargs: '"{main,scalalib,bsp}.__.testCached"' - java-version: '11' + # native-client requires MSVC build tools to be configured for x86 + use-graalvm: true millargs: '"example.scalalib.basic.__.fork.testCached"' - java-version: 17 + use-graalvm: false millargs: "'integration.{feature,failure}[_].fork.testCached'" - java-version: '11' + use-graalvm: false millargs: "'integration.invalidation[_].server.testCached'" - java-version: '11' + use-graalvm: false millargs: "contrib.__.testCached" uses: ./.github/workflows/run-mill-action.yml with: os: windows-latest java-version: ${{ matrix.java-version }} + use-graalvm: ${{ matrix.use-graalvm }} millargs: ${{ matrix.millargs }} itest: From 7fec4de1b5cd93ebfe6ff372a210fa9286a958eb Mon Sep 17 00:00:00 2001 From: Ajay Chandran Date: Mon, 2 Dec 2024 21:02:46 +0530 Subject: [PATCH 12/61] Fix Github Action --- .github/workflows/run-mill-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 5e3ecf44518..9198567e5e9 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -63,7 +63,7 @@ jobs: with: java-version: ${{ inputs.java-version }} distribution: temurin - if: !inputs.use-graalvm + if: ${{ !inputs.use-graalvm }} - uses: graalvm/setup-graalvm@v1 with: From f7966194cae3d518c794de3d71dd3964ebb4efcf Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 13:21:50 +0800 Subject: [PATCH 13/61] reuse native image scala --- dist/package.mill | 44 ++++--------------- mill-build/build.sc | 3 ++ .../src/mill/scalalib/NativeImageModule.scala | 1 + 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/dist/package.mill b/dist/package.mill index 01798a92f57..eed75f40b2f 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -8,8 +8,7 @@ import $file.ci.upload import scala.util.{Properties, Using} -// TODO extend NativeImageModule once available -object `package` extends RootModule with build.MillPublishJavaModule { +object `package` extends RootModule with build.MillPublishJavaModule with mill.scalalib.NativeImageModule{ /** * Version of [[dist]] meant for local integration testing within the Mill @@ -349,50 +348,23 @@ object `package` extends RootModule with build.MillPublishJavaModule { } } + def nativeImageExecutableName = if (Properties.isWin) "mill.exe" else "mill" + def mainClass = Some("mill.runner.client.MillClientMain") def nativeImage(args: String*): Command[PathRef] = Task.Command { - val dest = T.dest - val executableName = if (Properties.isWin) "mill.exe" else "mill" - val executable = Task.dest / executableName - - Task.traverse(allPublishModules)(m => m.publishLocalCached)() - val assembly = super.assembly().path - - val command = Seq.newBuilder[String] - .+=(nativeImageTool().path.toString) - .++=(Seq("-cp", assembly.toString)) - // Workaround for Zinc/JNA bug - // https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130 - .+=("-Djna.nosys=true") - .+=("--no-fallback") - .++=(args) - .+=("mill.runner.client.MillClientMain") - .+=(executableName) - .result() - os.proc(command).call(cwd = dest, stdout = os.Inherit) + val executable = Task.dest / nativeImageExecutableName() // concatenate executable and assembly as prescribed in: // https://github.com/com-lihaoyi/mill/issues/4007#issuecomment-2495933167 - Using(os.write.append.outputStream(executable)) { out => + Using(os.write.outputStream(executable)) { out => + out.write(os.read.bytes(super.nativeImage(args:_*)().path)) out.write(System.lineSeparator.getBytes) - out.write(os.read.bytes(assembly)) - out.flush() + out.write(os.read.bytes(assembly().path)) } + os.perms.set(executable, "rwxrwxrwx") PathRef(executable) } - def nativeImageTool: T[PathRef] = Task { - zincWorker().javaHome().map(_.path) - .orElse(sys.env.get("GRAALVM_HOME").map(os.Path(_))) match { - case Some(home) => - val tool = if (Properties.isWin) "native-image.cmd" else "native-image" - val path = home / "bin" / tool - if (os.exists(path)) PathRef(path) - else throw new RuntimeException(s"$path not found") - case None => - throw new RuntimeException("ZincWorkerModule.javaHome/GRAALVM_HOME not defined") - } - } def zincWorker = ModuleRef(ZincWorkerGraalvm) diff --git a/mill-build/build.sc b/mill-build/build.sc index 63c18f09970..cb3f8f82b0f 100644 --- a/mill-build/build.sc +++ b/mill-build/build.sc @@ -14,4 +14,7 @@ object `package` extends MillBuildRootModule { // TODO: document, why we have this dependency ivy"org.jsoup:jsoup:1.18.1" ) + + def nativeImageSource = Task.Source(Task.workspace / "scalalib/src/mill/scalalib/NativeImageModule.scala") + def allSourceFiles = super.allSourceFiles() ++ Seq(nativeImageSource()) } diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index 7ea1554c79a..b6f06b325f6 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -35,6 +35,7 @@ trait NativeImageModule extends RunModule with WithZincWorker { val command = Seq.newBuilder[String] .+=(nativeImageTool().path.toString) .++=(nativeImageOptions()) + .+=("--no-fallback") .++=(args) .+=("-cp") .+=(nativeImageClasspath().iterator.map(_.path).mkString(java.io.File.pathSeparator)) From eb4aec6947e4ccca4ee98880fd8093ee15f4f578 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 13:41:01 +0800 Subject: [PATCH 14/61] run all integration and example tests using native image --- dist/package.mill | 7 +++---- integration/package.mill | 5 +++-- scalalib/src/mill/scalalib/NativeImageModule.scala | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dist/package.mill b/dist/package.mill index eed75f40b2f..e0f3ccb8900 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -350,13 +350,11 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s def nativeImageExecutableName = if (Properties.isWin) "mill.exe" else "mill" def mainClass = Some("mill.runner.client.MillClientMain") - def nativeImage(args: String*): Command[PathRef] = Task.Command { + def nativeImage = Task { val executable = Task.dest / nativeImageExecutableName() - // concatenate executable and assembly as prescribed in: - // https://github.com/com-lihaoyi/mill/issues/4007#issuecomment-2495933167 Using(os.write.outputStream(executable)) { out => - out.write(os.read.bytes(super.nativeImage(args:_*)().path)) + out.write(os.read.bytes(super.nativeImage().path)) out.write(System.lineSeparator.getBytes) out.write(os.read.bytes(assembly().path)) } @@ -365,6 +363,7 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s PathRef(executable) } + def nativeImageOptions = Seq("--no-fallback") def zincWorker = ModuleRef(ZincWorkerGraalvm) diff --git a/integration/package.mill b/integration/package.mill index 4268947e764..9ccc213dc9c 100644 --- a/integration/package.mill +++ b/integration/package.mill @@ -56,8 +56,9 @@ object `package` extends RootModule { def testReleaseEnv = if (mode == "local") - T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.launcher().path.toString()) } - else T { Map("MILL_INTEGRATION_LAUNCHER" -> testMill().path.toString()) } + T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString()) } +// T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.launcher().path.toString()) } + else T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString) } def resources = IntegrationTestModule.this.resources() def runClasspath = IntegrationTestModule.this.runClasspath() diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index b6f06b325f6..20b9f7a49ca 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -29,14 +29,12 @@ trait NativeImageModule extends RunModule with WithZincWorker { * - passing debug options * - passing target specific options */ - def nativeImage(args: String*): Command[PathRef] = Task.Command { + def nativeImage: T[PathRef] = Task { val dest = T.dest val executableName = nativeImageExecutableName() val command = Seq.newBuilder[String] .+=(nativeImageTool().path.toString) .++=(nativeImageOptions()) - .+=("--no-fallback") - .++=(args) .+=("-cp") .+=(nativeImageClasspath().iterator.map(_.path).mkString(java.io.File.pathSeparator)) .+=(finalMainClass()) From 69d2401d3ad663089c3fa57a4a4597abeb3208e7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 13:42:12 +0800 Subject: [PATCH 15/61] todo-comment --- integration/package.mill | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/package.mill b/integration/package.mill index 9ccc213dc9c..b345cda9593 100644 --- a/integration/package.mill +++ b/integration/package.mill @@ -56,6 +56,7 @@ object `package` extends RootModule { def testReleaseEnv = if (mode == "local") + // TODO: revert this before merging T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString()) } // T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.launcher().path.toString()) } else T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString) } From 7caf5f86ebfe82ed467020d046bc0a1e7dba9bc2 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 13:48:18 +0800 Subject: [PATCH 16/61] . --- .github/actions/post-build-setup/action.yml | 20 ++++++++++---------- .github/workflows/post-build-selective.yml | 8 ++++---- .github/workflows/run-tests.yml | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/actions/post-build-setup/action.yml b/.github/actions/post-build-setup/action.yml index b7531097313..8f9d994756b 100644 --- a/.github/actions/post-build-setup/action.yml +++ b/.github/actions/post-build-setup/action.yml @@ -10,9 +10,9 @@ inputs: os: type: string - use-graalvm: - default: false - type: boolean +# use-graalvm: +# default: false +# type: boolean runs: using: "composite" steps: @@ -20,13 +20,13 @@ runs: with: java-version: ${{ inputs.java-version }} distribution: temurin - if: ${{ !inputs.use-graalvm }} - - - uses: graalvm/setup-graalvm@v1 - with: - java-version: ${{ inputs.java-version }} - distribution: graalvm-community - if: inputs.use-graalvm +# if: ${{ !inputs.use-graalvm }} +# +# - uses: graalvm/setup-graalvm@v1 +# with: +# java-version: ${{ inputs.java-version }} +# distribution: graalvm-community +# if: inputs.use-graalvm # Need to fix cached artifact file permissions because github actions screws it up # https://github.com/actions/upload-artifact/issues/38 diff --git a/.github/workflows/post-build-selective.yml b/.github/workflows/post-build-selective.yml index 485834e3d85..8a948f88828 100644 --- a/.github/workflows/post-build-selective.yml +++ b/.github/workflows/post-build-selective.yml @@ -8,9 +8,9 @@ on: java-version: required: true type: string - use-graalvm: - default: false - type: boolean +# use-graalvm: +# default: false +# type: boolean os: default: 'ubuntu-latest' type: string @@ -37,7 +37,7 @@ jobs: with: java-version: ${{ inputs.java-version }} os: ${{ inputs.os }} - use-graalvm: ${{ inputs.use-graalvm }} +# use-graalvm: ${{ inputs.use-graalvm }} - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d0907b3df68..859d97d3408 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -130,25 +130,25 @@ jobs: # the whole suite can take hours on windows v.s. half an hour on linux - java-version: 11 millargs: '"{main,scalalib,bsp}.__.test"' - use-graalvm: false +# use-graalvm: false - java-version: 11 millargs: '"example.scalalib.basic.__.fork.test"' - use-graalvm: true +# use-graalvm: true - java-version: 17 millargs: "'integration.{feature,failure}[_].fork.test'" - use-graalvm: false +# use-graalvm: false - java-version: 11 millargs: "'integration.invalidation[_].server.test'" - use-graalvm: false +# use-graalvm: false - java-version: 11 millargs: "contrib.__.test" - use-graalvm: false +# use-graalvm: false uses: ./.github/workflows/post-build-selective.yml with: os: windows-latest java-version: ${{ matrix.java-version }} - use-graalvm: ${{ matrix.use-graalvm }} +# use-graalvm: ${{ matrix.use-graalvm }} millargs: ${{ matrix.millargs }} itest: From e0de4ef67fd770effc59e1af67a6830e7012652a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 14:32:18 +0800 Subject: [PATCH 17/61] . --- .github/actions/post-build-setup/action.yml | 10 ----- .github/workflows/post-build-selective.yml | 4 -- .github/workflows/run-tests.yml | 46 +++++++++++---------- integration/package.mill | 34 +++++++++------ 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.github/actions/post-build-setup/action.yml b/.github/actions/post-build-setup/action.yml index 8f9d994756b..0b40e0ef272 100644 --- a/.github/actions/post-build-setup/action.yml +++ b/.github/actions/post-build-setup/action.yml @@ -10,9 +10,6 @@ inputs: os: type: string -# use-graalvm: -# default: false -# type: boolean runs: using: "composite" steps: @@ -20,13 +17,6 @@ runs: with: java-version: ${{ inputs.java-version }} distribution: temurin -# if: ${{ !inputs.use-graalvm }} -# -# - uses: graalvm/setup-graalvm@v1 -# with: -# java-version: ${{ inputs.java-version }} -# distribution: graalvm-community -# if: inputs.use-graalvm # Need to fix cached artifact file permissions because github actions screws it up # https://github.com/actions/upload-artifact/issues/38 diff --git a/.github/workflows/post-build-selective.yml b/.github/workflows/post-build-selective.yml index 8a948f88828..0abed682c93 100644 --- a/.github/workflows/post-build-selective.yml +++ b/.github/workflows/post-build-selective.yml @@ -8,9 +8,6 @@ on: java-version: required: true type: string -# use-graalvm: -# default: false -# type: boolean os: default: 'ubuntu-latest' type: string @@ -37,7 +34,6 @@ jobs: with: java-version: ${{ inputs.java-version }} os: ${{ inputs.os }} -# use-graalvm: ${{ inputs.use-graalvm }} - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 859d97d3408..698b2164881 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -65,53 +65,61 @@ jobs: install-android-sdk: false - java-version: 17 - millargs: "'example.javalib.__.local.test'" + millargs: "'example.javalib.__.local.server.test'" install-android-sdk: false - java-version: 17 - millargs: "'example.scalalib.__.local.test'" + millargs: "'example.scalalib.__.local.server.test'" install-android-sdk: false - java-version: 17 - millargs: "'example.kotlinlib.__.local.test'" + millargs: "'example.kotlinlib.__.local.server.test'" install-android-sdk: false - java-version: 17 - millargs: "'example.android.__.local.test'" + millargs: "'example.android.__.local.server.test'" install-android-sdk: true - java-version: 17 - millargs: "'example.{pythonlib,javascriptlib}.__.local.test'" + millargs: "'example.{pythonlib,javascriptlib}.__.local.server.test'" install-android-sdk: false - java-version: 11 - millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.test'" + millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'" install-android-sdk: false - java-version: 17 - millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.test'" + millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'" install-android-sdk: false - java-version: '17' - millargs: "'example.thirdparty[arrow].local.test'" + millargs: "'example.thirdparty[arrow].local.server.test'" install-android-sdk: false - java-version: 11 - millargs: "'example.{cli,fundamentals,depth,extending}.__.local.test'" + millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'" install-android-sdk: false # Most of these integration tests should not depend on which mode they # are run in, so just run them in `local` - java-version: '17' - millargs: "'integration.{failure,feature,ide}.__.local.test'" + millargs: "'integration.{failure,feature,ide}.__.local.server.test'" install-android-sdk: false # These invalidation tests need to be exercised in both execution modes # to make sure they work with and without -i/--no-server being passed - java-version: 17 - millargs: "'integration.invalidation.__.fork.test'" + millargs: "'integration.invalidation.__.assembly.fork.test'" install-android-sdk: false - java-version: 17 - millargs: "'integration.invalidation.__.server.test'" + millargs: "'integration.invalidation.__.assembly.server.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'integration.invalidation.__.native.fork.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'integration.invalidation.__.native.server.test'" install-android-sdk: false uses: ./.github/workflows/post-build-selective.yml @@ -130,25 +138,21 @@ jobs: # the whole suite can take hours on windows v.s. half an hour on linux - java-version: 11 millargs: '"{main,scalalib,bsp}.__.test"' -# use-graalvm: false - java-version: 11 - millargs: '"example.scalalib.basic.__.fork.test"' -# use-graalvm: true + millargs: '"example.scalalib.basic.__.assembly.fork.test"' - java-version: 17 - millargs: "'integration.{feature,failure}[_].fork.test'" -# use-graalvm: false + millargs: "'integration.{feature,failure}[_].assembly.fork.test'" + - java-version: 11 + millargs: "'integration.invalidation[_].assembly.server.test'" - java-version: 11 - millargs: "'integration.invalidation[_].server.test'" -# use-graalvm: false + millargs: "'integration.invalidation[_].native.server.test'" - java-version: 11 millargs: "contrib.__.test" -# use-graalvm: false uses: ./.github/workflows/post-build-selective.yml with: os: windows-latest java-version: ${{ matrix.java-version }} -# use-graalvm: ${{ matrix.use-graalvm }} millargs: ${{ matrix.millargs }} itest: diff --git a/integration/package.mill b/integration/package.mill index b345cda9593..ba95816b5d7 100644 --- a/integration/package.mill +++ b/integration/package.mill @@ -48,18 +48,13 @@ object `package` extends RootModule { "MILL_INTEGRATION_SERVER_MODE" -> (mode == "local" || mode == "server").toString, "MILL_LAUNCHER" -> build.dist.bootstrapLauncher().path.toString, "MILL_LAUNCHER_BAT" -> build.dist.bootstrapLauncherBat().path.toString, - ) ++ - testReleaseEnv() + "MILL_INTEGRATION_LAUNCHER" -> millIntegrationLauncher().path.toString + ) - def forkArgs = Task { super.forkArgs() ++ build.dist.forkArgs() } + def millIntegrationLauncher: T[PathRef] - def testReleaseEnv = - if (mode == "local") - // TODO: revert this before merging - T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString()) } -// T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.launcher().path.toString()) } - else T { Map("MILL_INTEGRATION_LAUNCHER" -> build.dist.nativeImage().path.toString) } + def forkArgs = Task { super.forkArgs() ++ build.dist.forkArgs() } def resources = IntegrationTestModule.this.resources() def runClasspath = IntegrationTestModule.this.runClasspath() @@ -71,9 +66,24 @@ object `package` extends RootModule { def testForkGrouping = discoveredTestClasses().grouped(1).toSeq } - object local extends ModeModule - object fork extends ModeModule - object server extends ModeModule + object local extends IntegrationLauncherModule { + def millIntegrationLauncher = build.dist.launcher() + } + object assembly extends IntegrationLauncherModule { + def millIntegrationLauncher = build.dist.assembly() + } + object native extends IntegrationLauncherModule { + def millIntegrationLauncher = build.dist.nativeImage() + } + trait IntegrationLauncherModule { + def millIntegrationLauncher: T[PathRef] + object fork extends ModeModule{ + def millIntegrationLauncher = IntegrationLauncherModule.this.millIntegrationLauncher + } + object server extends ModeModule{ + def millIntegrationLauncher = IntegrationLauncherModule.this.millIntegrationLauncher + } + } } object failure extends Cross[IntegrationCrossModule](build.listIn(millSourcePath / "failure")) From 6b76c49af271d7d8a4260138cfe30a1c2b2d3c1e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 14:34:17 +0800 Subject: [PATCH 18/61] . --- .github/actions/post-build-setup/action.yml | 1 + readme.adoc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/post-build-setup/action.yml b/.github/actions/post-build-setup/action.yml index 0b40e0ef272..772c5e2411b 100644 --- a/.github/actions/post-build-setup/action.yml +++ b/.github/actions/post-build-setup/action.yml @@ -10,6 +10,7 @@ inputs: os: type: string + runs: using: "composite" steps: diff --git a/readme.adoc b/readme.adoc index da79f167133..e850617a457 100644 --- a/readme.adoc +++ b/readme.adoc @@ -83,8 +83,8 @@ The following table contains the main ways you can test the code in |=== | Config | Automated Testing | Manual Testing | Manual Testing CI | In-Process Tests | `main.__.test`, `scalalib.test`, `contrib.buildinfo.test`, etc. | | -| Sub-Process w/o packaging/publishing| `example.\\__.local`, `integration.__.local` | `dist.run` | `test-mill-dev.sh` -| Sub-Process w/ packaging/publishing | `example.\\__.server`, `integration.__.server` | `dist.assembly` | `test-mill-release.sh` +| Sub-Process w/o packaging/publishing| `example.\\__.local.server`, `integration.__.local.server` | `dist.run` | `test-mill-dev.sh` +| Sub-Process w/ packaging/publishing | `example.\\__.assembly.server`, `integration.__.assembly.server` | `dist.assembly` | `test-mill-release.sh` | Bootstrapping: Building Mill with your current checkout of Mill | | `dist.installLocal` | `test-mill-bootstrap.sh` |=== From 390d20e15fe05982c4fd602327b7daa483413bf6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 14:40:09 +0800 Subject: [PATCH 19/61] . --- readme.adoc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/readme.adoc b/readme.adoc index e850617a457..bb3463e0bf6 100644 --- a/readme.adoc +++ b/readme.adoc @@ -116,7 +116,7 @@ and do not exercise the Mill script-file bootstrapping, transformation, and comp === Sub-Process Tests *without* Packaging/Publishing -`example.\\__.local` and `integration.__.local` tests run Mill end-to-end in a subprocess, +`example.\\__.local.server` and `integration.__.local.server` tests run Mill end-to-end in a subprocess, but *without* the expensive/slow steps of packaging the core packages into an assembly jar and publishing the remaining packages to `~/.ivy2/local`. @@ -151,7 +151,7 @@ You can reproduce any of the tests manually using `dist.run`, e.g. [source,bash] ---- -./mill "example.javalib.basic[1-simple].local" +./mill "example.javalib.basic[1-simple].local.server" ---- **Manual Test** @@ -171,7 +171,7 @@ You can reproduce any of the tests manually using `dist.run`, e.g. === Sub-Process Tests *with* Packaging/Publishing `example.\\__.server`, `integration.__.server`, `example.\\__.fork` and -`integration.__.fork` cover the same test cases as the `.local` tests described above, but +`integration.__.fork` cover the same test cases as the `.local.server` tests described above, but they perform packaging of the Mill core modules into an assembly jar, and publish the remaining modules to `~/.ivy2/local`. This results in a more realistic test environment, but at the cost of taking tens-of-seconds @@ -184,7 +184,22 @@ You can reproduce these tests manually using `dist.assembly`: ./mill dist.assembly && (cd example/basic/1-simple && ../../../out/dist/assembly.dest/mill run --text hello) ---- -There are two flavors of these tests: +There are two six of these tests, `.{local,assembly,native}.{server,fork}`. + +The first label specifies how the Mill code is packaged before testing + +1. `.local` runs using all compiled Mill code directly in the `out/` folder. This is the fastest + and should be used for most testing + +2. `.assembly` runs using the compiled Mill code either packaged into an assembly (for the Mill executable). + This is slower than `.local`, and normally isn't necessary unless you are debugging issues in the Mill + packaging logic. + +3. `.native` runs using the compiled Mill code packaged into an assembly with a Graal native binary launcher. + This is the slowest mode is only really necessary for debugging Mill's Graal native binary configuration. + +The second label specifies how the Mill process is managed during the test: + 1. `.server` test run the test cases with the default configuration, so consecutive commands run in the same long-lived background server process @@ -192,9 +207,9 @@ There are two flavors of these tests: 2. `.fork` test run the test cases with `--no-server`, meaning each command runs in a newly spawned Mill process -In general you should spend most of your time working with the `.local` version of the -`example` and `integration` tests to save time, and only run `.fork` -or `.server` once `.local` is passing. +In general you should spend most of your time working with the `.local.server` version of the +`example` and `integration` tests to save time, and only run `.assembly.fork` +or `.assembly.server` once `.local` is passing. === Bootstrapping: Building Mill with your current checkout of Mill From bb9655d6fd8199b7e8622893c5942b99afb55f5e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 14:40:42 +0800 Subject: [PATCH 20/61] . --- readme.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.adoc b/readme.adoc index bb3463e0bf6..1a72a7c37d1 100644 --- a/readme.adoc +++ b/readme.adoc @@ -208,8 +208,8 @@ The second label specifies how the Mill process is managed during the test: spawned Mill process In general you should spend most of your time working with the `.local.server` version of the -`example` and `integration` tests to save time, and only run `.assembly.fork` -or `.assembly.server` once `.local` is passing. +`example` and `integration` tests to save time, and only run the others if you have a specific +thing you want to test that needs those code paths to run. === Bootstrapping: Building Mill with your current checkout of Mill From 75e8b2f3b065e3663ebc64c1e6d018b3fce113fd Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 14:56:46 +0800 Subject: [PATCH 21/61] . --- .github/workflows/run-tests.yml | 13 +++++++------ integration/package.mill | 4 ++-- readme.adoc | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 698b2164881..36ca7dd228a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -114,12 +114,13 @@ jobs: millargs: "'integration.invalidation.__.assembly.server.test'" install-android-sdk: false + # Run some smoketests with Graal native image launcher - java-version: 17 - millargs: "'integration.invalidation.__.native.fork.test'" + millargs: "'example.javalib.__.native.server.test'" install-android-sdk: false - - java-version: 17 - millargs: "'integration.invalidation.__.native.server.test'" + - java-version: '17' + millargs: "'integration.{failure,feature,ide}.__.native.server.test'" install-android-sdk: false uses: ./.github/workflows/post-build-selective.yml @@ -141,11 +142,11 @@ jobs: - java-version: 11 millargs: '"example.scalalib.basic.__.assembly.fork.test"' - java-version: 17 - millargs: "'integration.{feature,failure}[_].assembly.fork.test'" + millargs: "'integration.{feature,failure}.__.assembly.fork.test'" - java-version: 11 - millargs: "'integration.invalidation[_].assembly.server.test'" + millargs: "'integration.invalidation.__.assembly.server.test'" - java-version: 11 - millargs: "'integration.invalidation[_].native.server.test'" + millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 millargs: "contrib.__.test" diff --git a/integration/package.mill b/integration/package.mill index ba95816b5d7..2dbfcfd079e 100644 --- a/integration/package.mill +++ b/integration/package.mill @@ -69,13 +69,13 @@ object `package` extends RootModule { object local extends IntegrationLauncherModule { def millIntegrationLauncher = build.dist.launcher() } - object assembly extends IntegrationLauncherModule { + object packaged extends IntegrationLauncherModule { def millIntegrationLauncher = build.dist.assembly() } object native extends IntegrationLauncherModule { def millIntegrationLauncher = build.dist.nativeImage() } - trait IntegrationLauncherModule { + trait IntegrationLauncherModule extends Module { def millIntegrationLauncher: T[PathRef] object fork extends ModeModule{ def millIntegrationLauncher = IntegrationLauncherModule.this.millIntegrationLauncher diff --git a/readme.adoc b/readme.adoc index 1a72a7c37d1..f4dc0faaf60 100644 --- a/readme.adoc +++ b/readme.adoc @@ -84,7 +84,7 @@ The following table contains the main ways you can test the code in | Config | Automated Testing | Manual Testing | Manual Testing CI | In-Process Tests | `main.__.test`, `scalalib.test`, `contrib.buildinfo.test`, etc. | | | Sub-Process w/o packaging/publishing| `example.\\__.local.server`, `integration.__.local.server` | `dist.run` | `test-mill-dev.sh` -| Sub-Process w/ packaging/publishing | `example.\\__.assembly.server`, `integration.__.assembly.server` | `dist.assembly` | `test-mill-release.sh` +| Sub-Process w/ packaging/publishing | `example.\\__.packaged.server`, `integration.__.packaged.server` | `dist.assembly` | `test-mill-release.sh` | Bootstrapping: Building Mill with your current checkout of Mill | | `dist.installLocal` | `test-mill-bootstrap.sh` |=== From b9ffe47251c84764aa19448588dfb2ddc0c94bb1 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 15:08:06 +0800 Subject: [PATCH 22/61] . --- .github/workflows/run-tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 36ca7dd228a..fecb1b5550f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -107,11 +107,11 @@ jobs: # These invalidation tests need to be exercised in both execution modes # to make sure they work with and without -i/--no-server being passed - java-version: 17 - millargs: "'integration.invalidation.__.assembly.fork.test'" + millargs: "'integration.invalidation.__.packaged.fork.test'" install-android-sdk: false - java-version: 17 - millargs: "'integration.invalidation.__.assembly.server.test'" + millargs: "'integration.invalidation.__.packaged.server.test'" install-android-sdk: false # Run some smoketests with Graal native image launcher @@ -140,11 +140,11 @@ jobs: - java-version: 11 millargs: '"{main,scalalib,bsp}.__.test"' - java-version: 11 - millargs: '"example.scalalib.basic.__.assembly.fork.test"' + millargs: '"example.scalalib.basic.__.packaged.fork.test"' - java-version: 17 - millargs: "'integration.{feature,failure}.__.assembly.fork.test'" + millargs: "'integration.{feature,failure}.__.packaged.fork.test'" - java-version: 11 - millargs: "'integration.invalidation.__.assembly.server.test'" + millargs: "'integration.invalidation.__.packaged.server.test'" - java-version: 11 millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 From 21e7cdd08af3926f6ef1280b57e824099dcb14a6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 15:50:03 +0800 Subject: [PATCH 23/61] . --- dist/package.mill | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/package.mill b/dist/package.mill index e0f3ccb8900..bcef55021b0 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -173,7 +173,7 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s mill.api.Result.Success(()) } catch { case e: Throwable => - mill.api.Result.Failure(s"dev.run failed with an exception. ${e.getMessage()}") + mill.api.Result.Failure(s"dist.run failed with an exception. ${e.getMessage()}") } } } @@ -350,6 +350,7 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s def nativeImageExecutableName = if (Properties.isWin) "mill.exe" else "mill" def mainClass = Some("mill.runner.client.MillClientMain") + def nativeImageClasspath = build.runner.client.runClasspath() def nativeImage = Task { val executable = Task.dest / nativeImageExecutableName() From c5a45983e9343ac82cc777ffb593b8eef76d06b7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 15:50:31 +0800 Subject: [PATCH 24/61] . --- ci/test-mill-bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/test-mill-bootstrap.sh b/ci/test-mill-bootstrap.sh index 924c92632c0..a203c9b66c7 100755 --- a/ci/test-mill-bootstrap.sh +++ b/ci/test-mill-bootstrap.sh @@ -20,4 +20,4 @@ ci/prepare-mill-bootstrap.sh # Run tests target/mill-release -i "__.compile" -target/mill-release -i "example.scalalib.basic[1-simple].server.test" +target/mill-release -i "example.scalalib.basic[1-simple].packaged.server.test" From b0e1ba21cf39201c9e94a7e3b2626703300078aa Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 16:28:12 +0800 Subject: [PATCH 25/61] . --- main/client/src/mill/main/client/Util.java | 12 +++++++++--- .../src/mill/runner/client/MillProcessLauncher.java | 2 +- runner/src/mill/runner/Watching.scala | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main/client/src/mill/main/client/Util.java b/main/client/src/mill/main/client/Util.java index c65c5fda938..d23d8cfaf20 100644 --- a/main/client/src/mill/main/client/Util.java +++ b/main/client/src/mill/main/client/Util.java @@ -166,7 +166,7 @@ static String sha1Hash(String path) throws NoSuchAlgorithmException { * * @return The non-empty lines of the files or an empty list, if the file does not exist */ - public static List readOptsFileLines(final File file) { + public static List readOptsFileLines(final File file) throws Exception { final List vmOptions = new LinkedList<>(); try (final Scanner sc = new Scanner(file)) { final Map env = System.getenv(); @@ -187,7 +187,7 @@ public static List readOptsFileLines(final File file) { * Interpolate variables in the form of ${VARIABLE} based on the given Map env. * Missing vars will be replaced by the empty string. */ - public static String interpolateEnvVars(String input, Map env) { + public static String interpolateEnvVars(String input, Map env) throws Exception { Matcher matcher = envInterpolatorPattern.matcher(input); // StringBuilder to store the result after replacing StringBuffer result = new StringBuffer(); @@ -197,7 +197,13 @@ public static String interpolateEnvVars(String input, Map env) { if (match.equals("$")) { matcher.appendReplacement(result, "\\$"); } else { - String envVarValue = env.containsKey(match) ? env.get(match) : ""; + String envVarValue = + // Hardcode support for PWD because the graal native launcher has it set to the + // working dir of the enclosing process, when we want it to be set to the working + // dir of the current process + match.equals("PWD") + ? new java.io.File(".").getAbsoluteFile().getCanonicalPath() + : env.containsKey(match) ? env.get(match) : ""; matcher.appendReplacement(result, envVarValue); } } diff --git a/runner/client/src/mill/runner/client/MillProcessLauncher.java b/runner/client/src/mill/runner/client/MillProcessLauncher.java index 52ca728599a..ab715ea148f 100644 --- a/runner/client/src/mill/runner/client/MillProcessLauncher.java +++ b/runner/client/src/mill/runner/client/MillProcessLauncher.java @@ -200,7 +200,7 @@ static List millLaunchJvmCommand(boolean setJnaNoSys) throws Exception { return vmOptions; } - static List readMillJvmOpts() { + static List readMillJvmOpts() throws Exception { return Util.readOptsFileLines(millJvmOptsFile()); } diff --git a/runner/src/mill/runner/Watching.scala b/runner/src/mill/runner/Watching.scala index a2f7e2b2ef1..cb9025338c4 100644 --- a/runner/src/mill/runner/Watching.scala +++ b/runner/src/mill/runner/Watching.scala @@ -82,7 +82,6 @@ object Watching { @tailrec def statWatchWait0(): Boolean = { if (watched.forall(_.validate())) { if (lookForEnterKey()) { - mill.main.client.DebugLog.println("ENTER KEY DETECTED") true } else { Thread.sleep(100) From d90524927c7b9b8c143c68e89165db0e348c185a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 16:28:41 +0800 Subject: [PATCH 26/61] . --- runner/client/src/mill/runner/client/MillProcessLauncher.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runner/client/src/mill/runner/client/MillProcessLauncher.java b/runner/client/src/mill/runner/client/MillProcessLauncher.java index ab715ea148f..b0a24517fe9 100644 --- a/runner/client/src/mill/runner/client/MillProcessLauncher.java +++ b/runner/client/src/mill/runner/client/MillProcessLauncher.java @@ -236,7 +236,6 @@ static void writeTerminalDims(boolean tputExists, Path serverDir) throws Excepti int width = size.getWidth(); int height = size.getHeight(); str = width + " " + height; - mill.main.client.DebugLog.println(str); } else if (!tputExists) { // Hardcoded size of a quarter screen terminal on 13" windows laptop str = "78 24"; From 92b622eb71dbed7dd2ed1ed11375d474a8d056a0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 16:43:49 +0800 Subject: [PATCH 27/61] . --- docs/modules/ROOT/pages/javalib/intro.adoc | 4 --- .../ROOT/pages/javalib/publishing.adoc | 5 ++++ docs/modules/ROOT/pages/kotlinlib/intro.adoc | 4 --- .../ROOT/pages/kotlinlib/publishing.adoc | 6 +++- docs/modules/ROOT/pages/scalalib/intro.adoc | 4 --- .../ROOT/pages/scalalib/publishing.adoc | 7 ++++- .../javalib/basic/7-native-image/build.mill | 26 ----------------- .../publishing/7-native-image/build.mill | 15 ++++++++++ .../7-native-image/foo/src/foo/App.java | 0 .../kotlinlib/basic/7-native-image/build.mill | 28 ------------------- .../publishing/7-native-image/build.mill | 17 +++++++++++ .../7-native-image/foo/src/foo/App.kt | 0 .../7-native-image/build.mill | 5 +++- .../7-native-image/foo/src/foo/App.scala | 0 14 files changed, 52 insertions(+), 69 deletions(-) delete mode 100644 example/javalib/basic/7-native-image/build.mill create mode 100644 example/javalib/publishing/7-native-image/build.mill rename example/javalib/{basic => publishing}/7-native-image/foo/src/foo/App.java (100%) delete mode 100644 example/kotlinlib/basic/7-native-image/build.mill create mode 100644 example/kotlinlib/publishing/7-native-image/build.mill rename example/kotlinlib/{basic => publishing}/7-native-image/foo/src/foo/App.kt (100%) rename example/scalalib/{basic => publishing}/7-native-image/build.mill (88%) rename example/scalalib/{basic => publishing}/7-native-image/foo/src/foo/App.scala (100%) diff --git a/docs/modules/ROOT/pages/javalib/intro.adoc b/docs/modules/ROOT/pages/javalib/intro.adoc index b6d0679112c..f8d5f124390 100644 --- a/docs/modules/ROOT/pages/javalib/intro.adoc +++ b/docs/modules/ROOT/pages/javalib/intro.adoc @@ -30,7 +30,3 @@ include::partial$example/javalib/basic/4-compat-modules.adoc[] == Realistic Java Example Project include::partial$example/javalib/basic/6-realistic.adoc[] - -== Building Native Image with Graal VM - -include::partial$example/javalib/basic/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/javalib/publishing.adoc b/docs/modules/ROOT/pages/javalib/publishing.adoc index d872eba1cb6..d3265556f8b 100644 --- a/docs/modules/ROOT/pages/javalib/publishing.adoc +++ b/docs/modules/ROOT/pages/javalib/publishing.adoc @@ -49,3 +49,8 @@ include::partial$example/javalib/publishing/5-jlink.adoc[] == Java Installers using `jpackage` include::partial$example/javalib/publishing/6-jpackage.adoc[] + + +== Building Native Image with Graal VM + +include::partial$example/javalib/basic/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/kotlinlib/intro.adoc b/docs/modules/ROOT/pages/kotlinlib/intro.adoc index 57d53d5269f..6de8bc33ee7 100644 --- a/docs/modules/ROOT/pages/kotlinlib/intro.adoc +++ b/docs/modules/ROOT/pages/kotlinlib/intro.adoc @@ -36,10 +36,6 @@ include::partial$example/kotlinlib/basic/4-compat-modules.adoc[] include::partial$example/kotlinlib/basic/6-realistic.adoc[] -== Building Native Image with Graal VM - -include::partial$example/kotlinlib/basic/7-native-image.adoc[] - == History Mill's Kotlin support originated as the third-party plugin diff --git a/docs/modules/ROOT/pages/kotlinlib/publishing.adoc b/docs/modules/ROOT/pages/kotlinlib/publishing.adoc index b2334c62bf9..c2bb8e86fb4 100644 --- a/docs/modules/ROOT/pages/kotlinlib/publishing.adoc +++ b/docs/modules/ROOT/pages/kotlinlib/publishing.adoc @@ -25,4 +25,8 @@ https://docs.oracle.com/en/java/javase/17/docs/specs/man/jpackage.html[JPackage] For more details, see: * xref:javalib/publishing.adoc#_java_app_and_bundles_using_jlink[Java App and Bundles using JLink] -* xref:javalib/publishing.adoc#_java_installers_using_jpackage[Java Installers using JPackage] \ No newline at end of file +* xref:javalib/publishing.adoc#_java_installers_using_jpackage[Java Installers using JPackage] + +== Building Native Image with Graal VM + +include::partial$example/kotlinlib/basic/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/scalalib/intro.adoc b/docs/modules/ROOT/pages/scalalib/intro.adoc index d9218b93c1d..21db19866b6 100644 --- a/docs/modules/ROOT/pages/scalalib/intro.adoc +++ b/docs/modules/ROOT/pages/scalalib/intro.adoc @@ -31,8 +31,4 @@ include::partial$example/scalalib/basic/4-compat-modules.adoc[] include::partial$example/scalalib/basic/6-realistic.adoc[] -== Building Native Image with Graal VM - -include::partial$example/scalalib/basic/7-native-image.adoc[] - diff --git a/docs/modules/ROOT/pages/scalalib/publishing.adoc b/docs/modules/ROOT/pages/scalalib/publishing.adoc index 7f2243edfa8..e5acdb5e101 100644 --- a/docs/modules/ROOT/pages/scalalib/publishing.adoc +++ b/docs/modules/ROOT/pages/scalalib/publishing.adoc @@ -24,4 +24,9 @@ https://docs.oracle.com/en/java/javase/17/docs/specs/man/jpackage.html[JPackage] For more details, see: * xref:javalib/publishing.adoc#_java_app_and_bundles_using_jlink[Java App and Bundles using JLink] -* xref:javalib/publishing.adoc#_java_installers_using_jpackage[Java Installers using JPackage] \ No newline at end of file +* xref:javalib/publishing.adoc#_java_installers_using_jpackage[Java Installers using JPackage] + + +== Building Native Image with Graal VM + +include::partial$example/scalalib/basic/7-native-image.adoc[] diff --git a/example/javalib/basic/7-native-image/build.mill b/example/javalib/basic/7-native-image/build.mill deleted file mode 100644 index 824669f5784..00000000000 --- a/example/javalib/basic/7-native-image/build.mill +++ /dev/null @@ -1,26 +0,0 @@ -//// SNIPPET:BUILD -package build -import mill._, javalib._ -import mill.define.ModuleRef - -object foo extends JavaModule with NativeImageModule { - - def zincWorker = ModuleRef(ZincWorkerGraalvm) - - object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = "graalvm-community:23.0.1" - } -} - -// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. -// NOTE: For build portability, it is recommended to use a custom JDK. - -/** Usage - -> ./mill foo.nativeImage -GraalVM Native Image: Generating...App... -Finished generating...App... - -> ./out/foo/nativeImage.dest/App -Hello, World! -*/ diff --git a/example/javalib/publishing/7-native-image/build.mill b/example/javalib/publishing/7-native-image/build.mill new file mode 100644 index 00000000000..e91dc728547 --- /dev/null +++ b/example/javalib/publishing/7-native-image/build.mill @@ -0,0 +1,15 @@ +//// SNIPPET:BUILD +package build +import mill._, javalib._ +import mill.define.ModuleRef + +object foo extends JavaModule with NativeImageModule { + + def zincWorker = ModuleRef(ZincWorkerGraalvm) + + object ZincWorkerGraalvm extends ZincWorkerModule { + def jvmId = "graalvm-community:23.0.1" + } +} + +//// SNIPPET:END diff --git a/example/javalib/basic/7-native-image/foo/src/foo/App.java b/example/javalib/publishing/7-native-image/foo/src/foo/App.java similarity index 100% rename from example/javalib/basic/7-native-image/foo/src/foo/App.java rename to example/javalib/publishing/7-native-image/foo/src/foo/App.java diff --git a/example/kotlinlib/basic/7-native-image/build.mill b/example/kotlinlib/basic/7-native-image/build.mill deleted file mode 100644 index 9cc8efc12ae..00000000000 --- a/example/kotlinlib/basic/7-native-image/build.mill +++ /dev/null @@ -1,28 +0,0 @@ -//// SNIPPET:BUILD -package build -import mill._, kotlinlib._ -import mill.define.ModuleRef - -object foo extends KotlinModule with NativeImageModule { - - def zincWorker = ModuleRef(ZincWorkerGraalvm) - - object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = "graalvm-community:23.0.1" - } - - def kotlinVersion = "1.9.24" -} - -// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. -// NOTE: For build portability, it is recommended to use a custom JDK. - -/** Usage - -> ./mill foo.nativeImage -GraalVM Native Image: Generating...AppKt... -Finished generating...AppKt... - -> ./out/foo/nativeImage.dest/AppKt -Hello, World! -*/ diff --git a/example/kotlinlib/publishing/7-native-image/build.mill b/example/kotlinlib/publishing/7-native-image/build.mill new file mode 100644 index 00000000000..57957db012a --- /dev/null +++ b/example/kotlinlib/publishing/7-native-image/build.mill @@ -0,0 +1,17 @@ +//// SNIPPET:BUILD +package build +import mill._, kotlinlib._ +import mill.define.ModuleRef + +object foo extends KotlinModule with NativeImageModule { + + def zincWorker = ModuleRef(ZincWorkerGraalvm) + + object ZincWorkerGraalvm extends ZincWorkerModule { + def jvmId = "graalvm-community:23.0.1" + } + + def kotlinVersion = "1.9.24" +} + +//// SNIPPET:END diff --git a/example/kotlinlib/basic/7-native-image/foo/src/foo/App.kt b/example/kotlinlib/publishing/7-native-image/foo/src/foo/App.kt similarity index 100% rename from example/kotlinlib/basic/7-native-image/foo/src/foo/App.kt rename to example/kotlinlib/publishing/7-native-image/foo/src/foo/App.kt diff --git a/example/scalalib/basic/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill similarity index 88% rename from example/scalalib/basic/7-native-image/build.mill rename to example/scalalib/publishing/7-native-image/build.mill index 4b00c457e4e..ab661dfbb55 100644 --- a/example/scalalib/basic/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -14,8 +14,11 @@ object foo extends ScalaModule with NativeImageModule { def scalaVersion = "2.13.11" } +//// SNIPPET:END +// // This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. -// NOTE: For build portability, it is recommended to use a custom JDK. +// NOTE: For build portability, it is recommended to use a custom JDK via a custom `ZincWorkerModule` overriding +// `def jvmId`. /** Usage diff --git a/example/scalalib/basic/7-native-image/foo/src/foo/App.scala b/example/scalalib/publishing/7-native-image/foo/src/foo/App.scala similarity index 100% rename from example/scalalib/basic/7-native-image/foo/src/foo/App.scala rename to example/scalalib/publishing/7-native-image/foo/src/foo/App.scala From 4862ea7ae76438b93a6c977a662e78196c7d4b77 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 21:38:25 +0800 Subject: [PATCH 28/61] . --- .github/workflows/run-tests.yml | 2 -- dist/package.mill | 5 +++-- docs/modules/ROOT/pages/javalib/publishing.adoc | 2 +- docs/modules/ROOT/pages/kotlinlib/publishing.adoc | 2 +- docs/modules/ROOT/pages/scalalib/publishing.adoc | 2 +- example/scalalib/publishing/7-native-image/build.mill | 6 +++--- scalalib/src/mill/scalalib/NativeImageModule.scala | 11 +---------- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fecb1b5550f..6ca73f7ee70 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -145,8 +145,6 @@ jobs: millargs: "'integration.{feature,failure}.__.packaged.fork.test'" - java-version: 11 millargs: "'integration.invalidation.__.packaged.server.test'" - - java-version: 11 - millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 millargs: "contrib.__.test" diff --git a/dist/package.mill b/dist/package.mill index bcef55021b0..251c6342a7a 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -352,10 +352,11 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s def mainClass = Some("mill.runner.client.MillClientMain") def nativeImageClasspath = build.runner.client.runClasspath() def nativeImage = Task { - val executable = Task.dest / nativeImageExecutableName() + val previous = super.nativeImage().path + val executable = Task.dest / previous.last Using(os.write.outputStream(executable)) { out => - out.write(os.read.bytes(super.nativeImage().path)) + out.write(os.read.bytes(previous)) out.write(System.lineSeparator.getBytes) out.write(os.read.bytes(assembly().path)) } diff --git a/docs/modules/ROOT/pages/javalib/publishing.adoc b/docs/modules/ROOT/pages/javalib/publishing.adoc index d3265556f8b..d5f29e9454f 100644 --- a/docs/modules/ROOT/pages/javalib/publishing.adoc +++ b/docs/modules/ROOT/pages/javalib/publishing.adoc @@ -53,4 +53,4 @@ include::partial$example/javalib/publishing/6-jpackage.adoc[] == Building Native Image with Graal VM -include::partial$example/javalib/basic/7-native-image.adoc[] +include::partial$example/javalib/publishing/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/kotlinlib/publishing.adoc b/docs/modules/ROOT/pages/kotlinlib/publishing.adoc index c2bb8e86fb4..4547af5c037 100644 --- a/docs/modules/ROOT/pages/kotlinlib/publishing.adoc +++ b/docs/modules/ROOT/pages/kotlinlib/publishing.adoc @@ -29,4 +29,4 @@ For more details, see: == Building Native Image with Graal VM -include::partial$example/kotlinlib/basic/7-native-image.adoc[] +include::partial$example/kotlinlib/publishing/7-native-image.adoc[] diff --git a/docs/modules/ROOT/pages/scalalib/publishing.adoc b/docs/modules/ROOT/pages/scalalib/publishing.adoc index e5acdb5e101..d315e3f1ab7 100644 --- a/docs/modules/ROOT/pages/scalalib/publishing.adoc +++ b/docs/modules/ROOT/pages/scalalib/publishing.adoc @@ -29,4 +29,4 @@ For more details, see: == Building Native Image with Graal VM -include::partial$example/scalalib/basic/7-native-image.adoc[] +include::partial$example/scalalib/publishing/7-native-image.adoc[] diff --git a/example/scalalib/publishing/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill index ab661dfbb55..45c0d67b78f 100644 --- a/example/scalalib/publishing/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -23,9 +23,9 @@ object foo extends ScalaModule with NativeImageModule { /** Usage > ./mill foo.nativeImage -GraalVM Native Image: Generating...App... -Finished generating...App... +GraalVM Native Image: Generating...native-image... +Finished generating...native-image... -> ./out/foo/nativeImage.dest/App +> ./out/foo/nativeImage.dest/native-image Hello, World! */ diff --git a/scalalib/src/mill/scalalib/NativeImageModule.scala b/scalalib/src/mill/scalalib/NativeImageModule.scala index 20b9f7a49ca..a71bcc60dbc 100644 --- a/scalalib/src/mill/scalalib/NativeImageModule.scala +++ b/scalalib/src/mill/scalalib/NativeImageModule.scala @@ -31,7 +31,7 @@ trait NativeImageModule extends RunModule with WithZincWorker { */ def nativeImage: T[PathRef] = Task { val dest = T.dest - val executableName = nativeImageExecutableName() + val executableName = "native-image" val command = Seq.newBuilder[String] .+=(nativeImageTool().path.toString) .++=(nativeImageOptions()) @@ -51,15 +51,6 @@ trait NativeImageModule extends RunModule with WithZincWorker { runClasspath() } - /** - * The name of the generated executable. - * Defaults to name of [[finalMainClass]] (with `exe` extension, on Windows). - */ - def nativeImageExecutableName: T[String] = Task { - val name = finalMainClass().split('.').last - if (Properties.isWin) s"$name.exe" else name - } - /** * Additional options for the `native-image` Tool. * From 7bfa2257ac82baf836dc8bc699be98906aae1308 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 21:41:21 +0800 Subject: [PATCH 29/61] . --- .github/workflows/run-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6ca73f7ee70..15416ac53dc 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -145,12 +145,14 @@ jobs: millargs: "'integration.{feature,failure}.__.packaged.fork.test'" - java-version: 11 millargs: "'integration.invalidation.__.packaged.server.test'" + - java-version: 11 + millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 millargs: "contrib.__.test" uses: ./.github/workflows/post-build-selective.yml with: - os: windows-latest + os: windows-amd64 java-version: ${{ matrix.java-version }} millargs: ${{ matrix.millargs }} From 1e3d0e54a7958f42fd2ca1014ed828055ccf1b7c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 21:41:58 +0800 Subject: [PATCH 30/61] . --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 15416ac53dc..fecb1b5550f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -152,7 +152,7 @@ jobs: uses: ./.github/workflows/post-build-selective.yml with: - os: windows-amd64 + os: windows-latest java-version: ${{ matrix.java-version }} millargs: ${{ matrix.millargs }} From f8107d4863c45e68aef738c19899f5e812ae4dff Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 22:03:56 +0800 Subject: [PATCH 31/61] . --- .github/workflows/run-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fecb1b5550f..54c71afd662 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -149,6 +149,8 @@ jobs: millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 millargs: "contrib.__.test" + - java-version: 11 + millargs: "example.javalib.publishing[7-native-image].local.server.test" uses: ./.github/workflows/post-build-selective.yml with: From 3e5277e29557df04aac6ab69f6f5d16fff2c78ba Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 8 Jan 2025 22:31:25 +0800 Subject: [PATCH 32/61] . --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 54c71afd662..f0368ec4c45 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -150,7 +150,7 @@ jobs: - java-version: 11 millargs: "contrib.__.test" - java-version: 11 - millargs: "example.javalib.publishing[7-native-image].local.server.test" + millargs: "example.javalib.publishing[7-native-image].packaged.server.test" uses: ./.github/workflows/post-build-selective.yml with: From 2258a1a4514e8c5dc080e4864108fd617d02aa4f Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 07:36:02 +0800 Subject: [PATCH 33/61] . --- .../mill/runner/client/MillClientMain.java | 15 +++--- .../runner/client/MillNoServerLauncher.java | 53 ------------------- 2 files changed, 6 insertions(+), 62 deletions(-) delete mode 100644 runner/client/src/mill/runner/client/MillNoServerLauncher.java diff --git a/runner/client/src/mill/runner/client/MillClientMain.java b/runner/client/src/mill/runner/client/MillClientMain.java index ab8a1db6868..1b9a7f1999d 100644 --- a/runner/client/src/mill/runner/client/MillClientMain.java +++ b/runner/client/src/mill/runner/client/MillClientMain.java @@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception { if (runNoServer) { // start in no-server mode - MillNoServerLauncher.runMain(args); + System.exit(MillProcessLauncher.launchMillNoServer(args)); } else try { // start in client-server mode @@ -68,14 +68,11 @@ public void preRun(Path serverDir) throws Exception { + "This could be caused by too many already running Mill instances " + "or by an unsupported platform.\n" + e.getMessage() + "\n"); - if (MillNoServerLauncher.load().canLoad) { - System.err.println("Trying to run Mill in-process ..."); - MillNoServerLauncher.runMain(args); - } else { - System.err.println( - "Loading Mill in-process isn't possible.\n" + "Please check your Mill installation!"); - throw e; - } + + System.err.println( + "Loading Mill in-process isn't possible.\n" + "Please check your Mill installation!"); + throw e; + } catch (Exception e) { System.err.println("Mill client failed with unknown exception"); e.printStackTrace(); diff --git a/runner/client/src/mill/runner/client/MillNoServerLauncher.java b/runner/client/src/mill/runner/client/MillNoServerLauncher.java deleted file mode 100644 index 21c9000b47a..00000000000 --- a/runner/client/src/mill/runner/client/MillNoServerLauncher.java +++ /dev/null @@ -1,53 +0,0 @@ -package mill.runner.client; - -import java.lang.reflect.Method; -import java.util.Optional; - -class MillNoServerLauncher { - - public static class LoadResult { - - public final Optional millMainMethod; - public final boolean canLoad; - public final long loadTime; - - public LoadResult(Optional millMainMethod, final long loadTime) { - this.millMainMethod = millMainMethod; - this.canLoad = millMainMethod.isPresent(); - this.loadTime = loadTime; - } - } - - private static Optional canLoad = Optional.empty(); - - public static LoadResult load() { - if (canLoad.isPresent()) { - return canLoad.get(); - } else { - long startTime = System.currentTimeMillis(); - Optional millMainMethod = Optional.empty(); - try { - Class millMainClass = Class.forName("mill.runner.MillMain"); - Method mainMethod = millMainClass.getMethod("main", String[].class); - millMainMethod = Optional.of(mainMethod); - } catch (ClassNotFoundException | NoSuchMethodException e) { - millMainMethod = Optional.empty(); - } - - long loadTime = System.currentTimeMillis() - startTime; - LoadResult result = new LoadResult(millMainMethod, loadTime); - canLoad = Optional.of(result); - return result; - } - } - - public static void runMain(String[] args) throws Exception { - LoadResult loadResult = load(); - if (loadResult.millMainMethod.isPresent()) { - int exitVal = MillProcessLauncher.launchMillNoServer(args); - System.exit(exitVal); - } else { - throw new RuntimeException("Cannot load mill.runner.MillMain class"); - } - } -} From c5a85d4f8ef7ecbc1264f7c81dbfeae7c23aa1b7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 07:42:40 +0800 Subject: [PATCH 34/61] . --- .github/workflows/run-tests.yml | 2 +- example/javalib/publishing/7-native-image/build.mill | 2 +- example/kotlinlib/publishing/7-native-image/build.mill | 2 +- example/scalalib/publishing/7-native-image/build.mill | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f0368ec4c45..1ccac2f8de4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -149,7 +149,7 @@ jobs: millargs: "'integration.invalidation.__.native.server.test'" - java-version: 11 millargs: "contrib.__.test" - - java-version: 11 + - java-version: 17 millargs: "example.javalib.publishing[7-native-image].packaged.server.test" uses: ./.github/workflows/post-build-selective.yml diff --git a/example/javalib/publishing/7-native-image/build.mill b/example/javalib/publishing/7-native-image/build.mill index e91dc728547..d54873b8be5 100644 --- a/example/javalib/publishing/7-native-image/build.mill +++ b/example/javalib/publishing/7-native-image/build.mill @@ -8,7 +8,7 @@ object foo extends JavaModule with NativeImageModule { def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = "graalvm-community:23.0.1" + def jvmId = "graalvm-community:17.0.7" } } diff --git a/example/kotlinlib/publishing/7-native-image/build.mill b/example/kotlinlib/publishing/7-native-image/build.mill index 57957db012a..d9dd8050766 100644 --- a/example/kotlinlib/publishing/7-native-image/build.mill +++ b/example/kotlinlib/publishing/7-native-image/build.mill @@ -8,7 +8,7 @@ object foo extends KotlinModule with NativeImageModule { def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = "graalvm-community:23.0.1" + def jvmId = "graalvm-community:17.0.7" } def kotlinVersion = "1.9.24" diff --git a/example/scalalib/publishing/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill index 45c0d67b78f..49fbe5c4f08 100644 --- a/example/scalalib/publishing/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -8,7 +8,7 @@ object foo extends ScalaModule with NativeImageModule { def zincWorker = ModuleRef(ZincWorkerGraalvm) object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = "graalvm-community:23.0.1" + def jvmId = "graalvm-community:17.0.7" } def scalaVersion = "2.13.11" From ab239e4b3e31d2a36e58bb53cdafe9a5d15068fc Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 09:01:12 +0800 Subject: [PATCH 35/61] debug --- .github/workflows/run-tests.yml | 142 +++++++++--------- .../publishing/7-native-image/build.mill | 4 + 2 files changed, 75 insertions(+), 71 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1ccac2f8de4..7bf38ce92d1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -52,67 +52,67 @@ jobs: # on the opposite version on Windows below, so we get decent coverage of # each test on each Java version and each operating system # We also try to group tests together to manually balance out the runtimes of each jobs - - java-version: 17 - millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.test'" - install-android-sdk: false - - - java-version: 11 - millargs: "'{scalajslib,scalanativelib,kotlinlib,pythonlib,javascriptlib}.__.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "contrib.__.test" - install-android-sdk: false - - - java-version: 17 - millargs: "'example.javalib.__.local.server.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "'example.scalalib.__.local.server.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "'example.kotlinlib.__.local.server.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "'example.android.__.local.server.test'" - install-android-sdk: true - - - java-version: 17 - millargs: "'example.{pythonlib,javascriptlib}.__.local.server.test'" - install-android-sdk: false - - - java-version: 11 - millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'" - install-android-sdk: false - - - java-version: '17' - millargs: "'example.thirdparty[arrow].local.server.test'" - install-android-sdk: false - - - java-version: 11 - millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'" - install-android-sdk: false - # Most of these integration tests should not depend on which mode they - # are run in, so just run them in `local` - - java-version: '17' - millargs: "'integration.{failure,feature,ide}.__.local.server.test'" - install-android-sdk: false - # These invalidation tests need to be exercised in both execution modes - # to make sure they work with and without -i/--no-server being passed - - java-version: 17 - millargs: "'integration.invalidation.__.packaged.fork.test'" - install-android-sdk: false - - - java-version: 17 - millargs: "'integration.invalidation.__.packaged.server.test'" - install-android-sdk: false +# - java-version: 17 +# millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.test'" +# install-android-sdk: false +# +# - java-version: 11 +# millargs: "'{scalajslib,scalanativelib,kotlinlib,pythonlib,javascriptlib}.__.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "contrib.__.test" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'example.javalib.__.local.server.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'example.scalalib.__.local.server.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'example.kotlinlib.__.local.server.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'example.android.__.local.server.test'" +# install-android-sdk: true +# +# - java-version: 17 +# millargs: "'example.{pythonlib,javascriptlib}.__.local.server.test'" +# install-android-sdk: false +# +# - java-version: 11 +# millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'" +# install-android-sdk: false +# +# - java-version: '17' +# millargs: "'example.thirdparty[arrow].local.server.test'" +# install-android-sdk: false +# +# - java-version: 11 +# millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'" +# install-android-sdk: false +# # Most of these integration tests should not depend on which mode they +# # are run in, so just run them in `local` +# - java-version: '17' +# millargs: "'integration.{failure,feature,ide}.__.local.server.test'" +# install-android-sdk: false +# # These invalidation tests need to be exercised in both execution modes +# # to make sure they work with and without -i/--no-server being passed +# - java-version: 17 +# millargs: "'integration.invalidation.__.packaged.fork.test'" +# install-android-sdk: false +# +# - java-version: 17 +# millargs: "'integration.invalidation.__.packaged.server.test'" +# install-android-sdk: false # Run some smoketests with Graal native image launcher - java-version: 17 @@ -137,18 +137,18 @@ jobs: include: # just run a subset of examples/ on Windows, because for some reason running # the whole suite can take hours on windows v.s. half an hour on linux - - java-version: 11 - millargs: '"{main,scalalib,bsp}.__.test"' - - java-version: 11 - millargs: '"example.scalalib.basic.__.packaged.fork.test"' - - java-version: 17 - millargs: "'integration.{feature,failure}.__.packaged.fork.test'" - - java-version: 11 - millargs: "'integration.invalidation.__.packaged.server.test'" +# - java-version: 11 +# millargs: '"{main,scalalib,bsp}.__.test"' +# - java-version: 11 +# millargs: '"example.scalalib.basic.__.packaged.fork.test"' +# - java-version: 17 +# millargs: "'integration.{feature,failure}.__.packaged.fork.test'" +# - java-version: 11 +# millargs: "'integration.invalidation.__.packaged.server.test'" - java-version: 11 millargs: "'integration.invalidation.__.native.server.test'" - - java-version: 11 - millargs: "contrib.__.test" +# - java-version: 11 +# millargs: "contrib.__.test" - java-version: 17 millargs: "example.javalib.publishing[7-native-image].packaged.server.test" diff --git a/example/scalalib/publishing/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill index 49fbe5c4f08..87ac5cbe50b 100644 --- a/example/scalalib/publishing/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -22,6 +22,10 @@ object foo extends ScalaModule with NativeImageModule { /** Usage +> ./mill show foo.ZincWorkerGraalvm.javaHome + +> ls /Users/runneradmin/AppData/Local/Coursier/Cache/arc/https/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.7/graalvm-community-jdk-17.0.7_windows-x64_bin.zip/graalvm-community-openjdk-17.0.7+7.1/lib/svm/clibraries/windows-amd64/include/ + > ./mill foo.nativeImage GraalVM Native Image: Generating...native-image... Finished generating...native-image... From 06ad95da2ea60554300ba6196e4f643a94f13da0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 09:31:16 +0800 Subject: [PATCH 36/61] . --- .github/workflows/run-tests.yml | 222 ++++++++++++++++++-------------- 1 file changed, 122 insertions(+), 100 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7bf38ce92d1..4601cf8f647 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,57 +1,79 @@ -name: Run Tests - -# We run full CI on push builds to main and on all pull requests -# -# Manual builds (workflow_dispatch) to the main branch are also published -# -# To maximize bug-catching changes while keeping CI times reasonable, we run: -# - All tests on Linux/Java17 -# - Fewer tests on Linux/Java11 and Windows/Java17 -# - Fewest tests on Windows/Java11 +# Uncommment this to replace the rest of the file when you want to debug stuff in CI +name: Run Debug on: push: pull_request: workflow_dispatch: -# cancel older runs of a pull request; -# this will not cancel anything for normal git pushes -concurrency: - group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - jobs: - # Jobs are listed in rough order of priority: if multiple jobs fail, the first job - # in the list should be the one that's most worth looking into - build-linux: - uses: ./.github/workflows/pre-build.yml - with: - os: ubuntu-latest - - build-windows: - uses: ./.github/workflows/pre-build.yml - with: - os: windows-latest - test-docs: - runs-on: ubuntu-latest +# runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - - run: ./mill -i docs.githubPages + docs.checkBrokenLinks + - run: ./mill show dist.ZincWorkerGraalvm.javaHome - linux: - needs: build-linux - strategy: - fail-fast: false - matrix: +# - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - include: - # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and - # on the opposite version on Windows below, so we get decent coverage of - # each test on each Java version and each operating system - # We also try to group tests together to manually balance out the runtimes of each jobs +# +# +#name: Run Tests +# +## We run full CI on push builds to main and on all pull requests +## +## Manual builds (workflow_dispatch) to the main branch are also published +## +## To maximize bug-catching changes while keeping CI times reasonable, we run: +## - All tests on Linux/Java17 +## - Fewer tests on Linux/Java11 and Windows/Java17 +## - Fewest tests on Windows/Java11 +# +#on: +# push: +# pull_request: +# workflow_dispatch: +# +## cancel older runs of a pull request; +## this will not cancel anything for normal git pushes +#concurrency: +# group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }} +# cancel-in-progress: true +# +#jobs: +# # Jobs are listed in rough order of priority: if multiple jobs fail, the first job +# # in the list should be the one that's most worth looking into +# build-linux: +# uses: ./.github/workflows/pre-build.yml +# with: +# os: ubuntu-latest +# +# build-windows: +# uses: ./.github/workflows/pre-build.yml +# with: +# os: windows-latest +# +# test-docs: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# with: { fetch-depth: 0 } +# +# - run: ./mill -i docs.githubPages + docs.checkBrokenLinks +# +# linux: +# needs: build-linux +# strategy: +# fail-fast: false +# matrix: +# +# include: +# # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and +# # on the opposite version on Windows below, so we get decent coverage of +# # each test on each Java version and each operating system +# # We also try to group tests together to manually balance out the runtimes of each jobs # - java-version: 17 # millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.test'" # install-android-sdk: false @@ -113,30 +135,30 @@ jobs: # - java-version: 17 # millargs: "'integration.invalidation.__.packaged.server.test'" # install-android-sdk: false - - # Run some smoketests with Graal native image launcher - - java-version: 17 - millargs: "'example.javalib.__.native.server.test'" - install-android-sdk: false - - - java-version: '17' - millargs: "'integration.{failure,feature,ide}.__.native.server.test'" - install-android-sdk: false - - uses: ./.github/workflows/post-build-selective.yml - with: - install-android-sdk: ${{ matrix.install-android-sdk }} - java-version: ${{ matrix.java-version }} - millargs: ${{ matrix.millargs }} - - windows: - needs: build-windows - strategy: - fail-fast: false - matrix: - include: - # just run a subset of examples/ on Windows, because for some reason running - # the whole suite can take hours on windows v.s. half an hour on linux +# +# # Run some smoketests with Graal native image launcher +# - java-version: 17 +# millargs: "'example.javalib.__.native.server.test'" +# install-android-sdk: false +# +# - java-version: '17' +# millargs: "'integration.{failure,feature,ide}.__.native.server.test'" +# install-android-sdk: false +# +# uses: ./.github/workflows/post-build-selective.yml +# with: +# install-android-sdk: ${{ matrix.install-android-sdk }} +# java-version: ${{ matrix.java-version }} +# millargs: ${{ matrix.millargs }} +# +# windows: +# needs: build-windows +# strategy: +# fail-fast: false +# matrix: +# include: +# # just run a subset of examples/ on Windows, because for some reason running +# # the whole suite can take hours on windows v.s. half an hour on linux # - java-version: 11 # millargs: '"{main,scalalib,bsp}.__.test"' # - java-version: 11 @@ -145,41 +167,41 @@ jobs: # millargs: "'integration.{feature,failure}.__.packaged.fork.test'" # - java-version: 11 # millargs: "'integration.invalidation.__.packaged.server.test'" - - java-version: 11 - millargs: "'integration.invalidation.__.native.server.test'" +# - java-version: 11 +# millargs: "'integration.invalidation.__.native.server.test'" # - java-version: 11 # millargs: "contrib.__.test" - - java-version: 17 - millargs: "example.javalib.publishing[7-native-image].packaged.server.test" - - uses: ./.github/workflows/post-build-selective.yml - with: - os: windows-latest - java-version: ${{ matrix.java-version }} - millargs: ${{ matrix.millargs }} - - itest: - needs: build-linux - strategy: - fail-fast: false - matrix: - 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 - - java-version: 17 # Have one job on default JVM - buildcmd: ci/test-mill-bootstrap.sh - - uses: ./.github/workflows/post-build-raw.yml - with: - java-version: ${{ matrix.java-version }} - buildcmd: ${{ matrix.buildcmd }} - - # Scalafmt, Mima, and Scalafix job runs last because it's the least important: - # usually just an automated or mechanical manual fix to do before merging - lint-autofix: - needs: build-linux - uses: ./.github/workflows/post-build-raw.yml - with: - java-version: '17' - buildcmd: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources + __.mimaReportBinaryIssues + __.fix --check + mill.javalib.palantirformat.PalantirFormatModule/ --check + mill.kotlinlib.ktlint.KtlintModule/checkFormatAll +# - java-version: 17 +# millargs: "example.javalib.publishing[7-native-image].packaged.server.test" +# +# uses: ./.github/workflows/post-build-selective.yml +# with: +# os: windows-latest +# java-version: ${{ matrix.java-version }} +# millargs: ${{ matrix.millargs }} +# +# itest: +# needs: build-linux +# strategy: +# fail-fast: false +# matrix: +# 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 +# - java-version: 17 # Have one job on default JVM +# buildcmd: ci/test-mill-bootstrap.sh +# +# uses: ./.github/workflows/post-build-raw.yml +# with: +# java-version: ${{ matrix.java-version }} +# buildcmd: ${{ matrix.buildcmd }} +# +# # Scalafmt, Mima, and Scalafix job runs last because it's the least important: +# # usually just an automated or mechanical manual fix to do before merging +# lint-autofix: +# needs: build-linux +# uses: ./.github/workflows/post-build-raw.yml +# with: +# java-version: '17' +# buildcmd: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources + __.mimaReportBinaryIssues + __.fix --check + mill.javalib.palantirformat.PalantirFormatModule/ --check + mill.kotlinlib.ktlint.KtlintModule/checkFormatAll From 817d7624cacca1db9808ebe30844edfd8865b966 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 09:31:58 +0800 Subject: [PATCH 37/61] . --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4601cf8f647..df9f2fc3ecf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ on: jobs: test-docs: # runs-on: ubuntu-latest - runs-on: windows-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } From 2576c7843d1fa32d9d99d59087ef9549db8a8a69 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:14:50 +0800 Subject: [PATCH 38/61] . --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index df9f2fc3ecf..b0b8ac8eb5c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,7 +13,10 @@ jobs: steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' - run: ./mill show dist.ZincWorkerGraalvm.javaHome # - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' From aec277d0fe6abc1c9c799341a5a8a3eff121a420 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:15:30 +0800 Subject: [PATCH 39/61] . --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b0b8ac8eb5c..e7ea38337df 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,7 +12,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 - with: { fetch-depth: 0 } + with: { fetch-depth: 1 } - uses: actions/setup-java@v4 with: distribution: 'temurin' From 2d197dfc77d4a8c4d12c5a79ee527d8cdde0d2bf Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:16:52 +0800 Subject: [PATCH 40/61] . --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e7ea38337df..e5e44c64334 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - test-docs: + debug: # runs-on: ubuntu-latest runs-on: windows-latest steps: From b9fc16d8fd03e9b6ea58a92e2c2fad586b7e9cfb Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:20:47 +0800 Subject: [PATCH 41/61] . --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e5e44c64334..23ee216f43a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,8 +18,11 @@ jobs: distribution: 'temurin' java-version: '17' - run: ./mill show dist.ZincWorkerGraalvm.javaHome + + - run: find /Users/runneradmin/AppData/Local/Coursier/cache/arc/https/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-23.0.1/graalvm-community-jdk-23.0.1_windows-x64_bin.zip/graalvm-community-openjdk-23.0.1+11.1 + shell: bash -# - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' # # From 1a86f68fac9d71453884c6c2490d3af85fb3c169 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:23:55 +0800 Subject: [PATCH 42/61] . --- .github/workflows/run-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 23ee216f43a..692ddeaa999 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,8 +19,7 @@ jobs: java-version: '17' - run: ./mill show dist.ZincWorkerGraalvm.javaHome - - run: find /Users/runneradmin/AppData/Local/Coursier/cache/arc/https/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-23.0.1/graalvm-community-jdk-23.0.1_windows-x64_bin.zip/graalvm-community-openjdk-23.0.1+11.1 - shell: bash + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' From cf456d1464ca5beddfb3942fb45e47ab87ae761c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:31:28 +0800 Subject: [PATCH 43/61] . --- .github/workflows/run-tests.yml | 2 ++ example/scalalib/publishing/7-native-image/build.mill | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 692ddeaa999..b3c7545274d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -21,6 +21,8 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64\\include + - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' # diff --git a/example/scalalib/publishing/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill index 87ac5cbe50b..e546aef97fe 100644 --- a/example/scalalib/publishing/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -24,7 +24,7 @@ object foo extends ScalaModule with NativeImageModule { > ./mill show foo.ZincWorkerGraalvm.javaHome -> ls /Users/runneradmin/AppData/Local/Coursier/Cache/arc/https/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.7/graalvm-community-jdk-17.0.7_windows-x64_bin.zip/graalvm-community-openjdk-17.0.7+7.1/lib/svm/clibraries/windows-amd64/include/ +> ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\Cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include > ./mill foo.nativeImage GraalVM Native Image: Generating...native-image... From 18e3f62ca49cd50ca6ba334d9bbedfcdddbe4841 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:34:01 +0800 Subject: [PATCH 44/61] . --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b3c7545274d..ae6133a150c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,7 +20,10 @@ jobs: - run: ./mill show dist.ZincWorkerGraalvm.javaHome - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 - + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64 - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64\\include - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' From 6d7a7a426615ef0417c44d4d3a24189509f13071 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:39:38 +0800 Subject: [PATCH 45/61] . --- .github/workflows/run-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ae6133a150c..86b9489034a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -24,7 +24,6 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64 - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64\\include - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' From 91e908f0aba5d2ccece6cdc374cc1e3816213541 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:46:04 +0800 Subject: [PATCH 46/61] . --- .github/workflows/run-tests.yml | 3 +++ example/scalalib/publishing/7-native-image/build.mill | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 86b9489034a..e8504caafa4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -27,6 +27,9 @@ jobs: - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + if: always() + # # #name: Run Tests diff --git a/example/scalalib/publishing/7-native-image/build.mill b/example/scalalib/publishing/7-native-image/build.mill index e546aef97fe..93a9b7a4f8a 100644 --- a/example/scalalib/publishing/7-native-image/build.mill +++ b/example/scalalib/publishing/7-native-image/build.mill @@ -24,8 +24,6 @@ object foo extends ScalaModule with NativeImageModule { > ./mill show foo.ZincWorkerGraalvm.javaHome -> ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\Cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include - > ./mill foo.nativeImage GraalVM Native Image: Generating...native-image... Finished generating...native-image... From 864cb4b861336f88ff15ec2259f84ceb0e50dea7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 10:53:28 +0800 Subject: [PATCH 47/61] . --- .github/workflows/run-tests.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e8504caafa4..7fd4531847d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -27,7 +27,19 @@ jobs: - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h if: always() # From 3cb03a272a90f85a7a736b4f3bdbcf409e2f20d3 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:06:45 +0800 Subject: [PATCH 48/61] . --- .github/workflows/run-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7fd4531847d..86598510fb9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,7 +18,7 @@ jobs: distribution: 'temurin' java-version: '17' - run: ./mill show dist.ZincWorkerGraalvm.javaHome - + env: COURSIER_CACHE=/coursier - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm @@ -26,7 +26,7 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64 - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - + env: COURSIER_CACHE=/coursier - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib From 4500c7dc12f78418d939f151df54b1a14a0dfc63 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:09:54 +0800 Subject: [PATCH 49/61] . --- .github/workflows/run-tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 86598510fb9..ca47ee389eb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,7 +18,8 @@ jobs: distribution: 'temurin' java-version: '17' - run: ./mill show dist.ZincWorkerGraalvm.javaHome - env: COURSIER_CACHE=/coursier + env: + COURSIER_CACHE: /coursier - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm @@ -26,7 +27,8 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64 - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - env: COURSIER_CACHE=/coursier + env: + COURSIER_CACHE: /coursier - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib From a109b80ddbf646a9100082f5e473019607e7c50f Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:18:05 +0800 Subject: [PATCH 50/61] . --- .github/workflows/run-tests.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ca47ee389eb..904002f2784 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,18 +17,11 @@ jobs: with: distribution: 'temurin' java-version: '17' - - run: ./mill show dist.ZincWorkerGraalvm.javaHome - env: - COURSIER_CACHE: /coursier - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1 - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-23.0.1\\graalvm-community-jdk-23.0.1_windows-x64_bin.zip\\graalvm-community-openjdk-23.0.1+11.1\\lib\\svm\\clibraries\\windows-amd64 + + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - env: - COURSIER_CACHE: /coursier + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib @@ -39,7 +32,7 @@ jobs: if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 if: always() - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include + if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h if: always() From afa686b883e379443a8159aa315fd2d1d7faa4e2 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:32:52 +0800 Subject: [PATCH 51/61] . --- .github/workflows/run-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 904002f2784..3b30ce691e2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -31,7 +31,6 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 - if: always() if: always() - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h From d94383104174897aafe2cbd4e3cef876a68ed49a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:36:40 +0800 Subject: [PATCH 52/61] . --- .github/workflows/run-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3b30ce691e2..e33c9f2be6c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,8 +18,6 @@ jobs: distribution: 'temurin' java-version: '17' - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include - - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 @@ -36,6 +34,7 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h if: always() + - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' # # #name: Run Tests From e2f899f09569622dcfa3a4ea971ce407a501e165 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:37:48 +0800 Subject: [PATCH 53/61] . --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e33c9f2be6c..7e86db9c69f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -35,6 +35,7 @@ jobs: if: always() - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + if: always() # # #name: Run Tests From e3edde415bdd6c251373661af931b87c3dcd39e2 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:46:35 +0800 Subject: [PATCH 54/61] . --- .github/workflows/run-tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7e86db9c69f..462e5b3eef2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,20 +22,27 @@ jobs: - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries if: always() - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h if: always() - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' if: always() + + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 + if: always() # # #name: Run Tests From 7264a0911df4b1d4bb8557652efa12ace7df4f45 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 11:50:01 +0800 Subject: [PATCH 55/61] . --- .github/workflows/run-tests.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 462e5b3eef2..cc27a8c1526 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,28 +20,13 @@ jobs: - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1 - if: always() - - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib - if: always() - - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm - if: always() - - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries - if: always() - - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 - if: always() - - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include if: always() - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' if: always() - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64 + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include if: always() # # From a4c60bcf4b88421495cfe0193e73d6f8296f929c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 12:01:29 +0800 Subject: [PATCH 56/61] . --- .github/workflows/run-tests.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index cc27a8c1526..015160cc8b1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,6 +20,18 @@ jobs: - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' + - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\aarch64cpufeatures.h + if: always() + + - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\amd64cpufeatures.h + if: always() + + - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\amd64hotspotcpuinfo.h + if: always() + + - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h + if: always() + - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include if: always() From 2bb648ce20ff3c8c047ae643ccc49abf0e9980e8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 12:04:57 +0800 Subject: [PATCH 57/61] . --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 015160cc8b1..4e3166c65f3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,7 +19,8 @@ jobs: java-version: '17' - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - + env: + COURSIER_CACHE: D:/a/mill/coursier_cache - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\aarch64cpufeatures.h if: always() @@ -37,6 +38,8 @@ jobs: - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' if: always() + env: + COURSIER_CACHE: D:/a/mill/coursier_cache - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include if: always() From bf51d8cbababd03282875e45a57b609565e9b3ee Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 12:13:49 +0800 Subject: [PATCH 58/61] disable windows for now --- .github/workflows/run-tests.yml | 404 +++++++++++++++----------------- 1 file changed, 189 insertions(+), 215 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4e3166c65f3..37c3ade7b3e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,232 +1,206 @@ # Uncommment this to replace the rest of the file when you want to debug stuff in CI -name: Run Debug +#name: Run Debug +# +#on: +# push: +# pull_request: +# workflow_dispatch: +# +#jobs: +# debug: +## runs-on: ubuntu-latest +# runs-on: windows-latest +# steps: +# - uses: actions/checkout@v4 +# with: { fetch-depth: 1 } +# - uses: actions/setup-java@v4 +# with: +# distribution: 'temurin' +# java-version: '17' +# +# - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' +## +# +name: Run Tests + +# We run full CI on push builds to main and on all pull requests +# +# Manual builds (workflow_dispatch) to the main branch are also published +# +# To maximize bug-catching changes while keeping CI times reasonable, we run: +# - All tests on Linux/Java17 +# - Fewer tests on Linux/Java11 and Windows/Java17 +# - Fewest tests on Windows/Java11 on: push: pull_request: workflow_dispatch: +# cancel older runs of a pull request; +# this will not cancel anything for normal git pushes +concurrency: + group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: - debug: -# runs-on: ubuntu-latest - runs-on: windows-latest + # Jobs are listed in rough order of priority: if multiple jobs fail, the first job + # in the list should be the one that's most worth looking into + build-linux: + uses: ./.github/workflows/pre-build.yml + with: + os: ubuntu-latest + + build-windows: + uses: ./.github/workflows/pre-build.yml + with: + os: windows-latest + + test-docs: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: { fetch-depth: 1 } - - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' + with: { fetch-depth: 0 } - - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - env: - COURSIER_CACHE: D:/a/mill/coursier_cache - - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\aarch64cpufeatures.h - if: always() + - run: ./mill -i docs.githubPages + docs.checkBrokenLinks - - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\amd64cpufeatures.h - if: always() + linux: + needs: build-linux + strategy: + fail-fast: false + matrix: - - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\amd64hotspotcpuinfo.h - if: always() + include: + # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and + # on the opposite version on Windows below, so we get decent coverage of + # each test on each Java version and each operating system + # We also try to group tests together to manually balance out the runtimes of each jobs + - java-version: 17 + millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.test'" + install-android-sdk: false - - run: type C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include\\riscv64cpufeatures.h - if: always() + - java-version: 11 + millargs: "'{scalajslib,scalanativelib,kotlinlib,pythonlib,javascriptlib}.__.test'" + install-android-sdk: false - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include - if: always() + - java-version: 17 + millargs: "contrib.__.test" + install-android-sdk: false - - run: ./mill 'example.javalib.publishing[7-native-image].packaged.server.test' - if: always() - env: - COURSIER_CACHE: D:/a/mill/coursier_cache + - java-version: 17 + millargs: "'example.javalib.__.local.server.test'" + install-android-sdk: false - - run: ls C:\\Users\\runneradmin\\AppData\\Local\\Coursier\\cache\\arc\\https\\github.com\\graalvm\\graalvm-ce-builds\\releases\\download\\jdk-17.0.7\\graalvm-community-jdk-17.0.7_windows-x64_bin.zip\\graalvm-community-openjdk-17.0.7+7.1\\lib\\svm\\clibraries\\windows-amd64\\include - if: always() -# -# -#name: Run Tests -# -## We run full CI on push builds to main and on all pull requests -## -## Manual builds (workflow_dispatch) to the main branch are also published -## -## To maximize bug-catching changes while keeping CI times reasonable, we run: -## - All tests on Linux/Java17 -## - Fewer tests on Linux/Java11 and Windows/Java17 -## - Fewest tests on Windows/Java11 -# -#on: -# push: -# pull_request: -# workflow_dispatch: -# -## cancel older runs of a pull request; -## this will not cancel anything for normal git pushes -#concurrency: -# group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }} -# cancel-in-progress: true -# -#jobs: -# # Jobs are listed in rough order of priority: if multiple jobs fail, the first job -# # in the list should be the one that's most worth looking into -# build-linux: -# uses: ./.github/workflows/pre-build.yml -# with: -# os: ubuntu-latest -# -# build-windows: -# uses: ./.github/workflows/pre-build.yml -# with: -# os: windows-latest -# -# test-docs: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# with: { fetch-depth: 0 } -# -# - run: ./mill -i docs.githubPages + docs.checkBrokenLinks -# -# linux: -# needs: build-linux -# strategy: -# fail-fast: false -# matrix: -# -# include: -# # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and -# # on the opposite version on Windows below, so we get decent coverage of -# # each test on each Java version and each operating system -# # We also try to group tests together to manually balance out the runtimes of each jobs -# - java-version: 17 -# millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.test'" -# install-android-sdk: false -# -# - java-version: 11 -# millargs: "'{scalajslib,scalanativelib,kotlinlib,pythonlib,javascriptlib}.__.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "contrib.__.test" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'example.javalib.__.local.server.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'example.scalalib.__.local.server.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'example.kotlinlib.__.local.server.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'example.android.__.local.server.test'" -# install-android-sdk: true -# -# - java-version: 17 -# millargs: "'example.{pythonlib,javascriptlib}.__.local.server.test'" -# install-android-sdk: false -# -# - java-version: 11 -# millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'" -# install-android-sdk: false -# -# - java-version: '17' -# millargs: "'example.thirdparty[arrow].local.server.test'" -# install-android-sdk: false -# -# - java-version: 11 -# millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'" -# install-android-sdk: false -# # Most of these integration tests should not depend on which mode they -# # are run in, so just run them in `local` -# - java-version: '17' -# millargs: "'integration.{failure,feature,ide}.__.local.server.test'" -# install-android-sdk: false -# # These invalidation tests need to be exercised in both execution modes -# # to make sure they work with and without -i/--no-server being passed -# - java-version: 17 -# millargs: "'integration.invalidation.__.packaged.fork.test'" -# install-android-sdk: false -# -# - java-version: 17 -# millargs: "'integration.invalidation.__.packaged.server.test'" -# install-android-sdk: false -# -# # Run some smoketests with Graal native image launcher -# - java-version: 17 -# millargs: "'example.javalib.__.native.server.test'" -# install-android-sdk: false -# -# - java-version: '17' -# millargs: "'integration.{failure,feature,ide}.__.native.server.test'" -# install-android-sdk: false -# -# uses: ./.github/workflows/post-build-selective.yml -# with: -# install-android-sdk: ${{ matrix.install-android-sdk }} -# java-version: ${{ matrix.java-version }} -# millargs: ${{ matrix.millargs }} -# -# windows: -# needs: build-windows -# strategy: -# fail-fast: false -# matrix: -# include: -# # just run a subset of examples/ on Windows, because for some reason running -# # the whole suite can take hours on windows v.s. half an hour on linux -# - java-version: 11 -# millargs: '"{main,scalalib,bsp}.__.test"' -# - java-version: 11 -# millargs: '"example.scalalib.basic.__.packaged.fork.test"' -# - java-version: 17 -# millargs: "'integration.{feature,failure}.__.packaged.fork.test'" -# - java-version: 11 -# millargs: "'integration.invalidation.__.packaged.server.test'" -# - java-version: 11 -# millargs: "'integration.invalidation.__.native.server.test'" -# - java-version: 11 -# millargs: "contrib.__.test" -# - java-version: 17 -# millargs: "example.javalib.publishing[7-native-image].packaged.server.test" -# -# uses: ./.github/workflows/post-build-selective.yml -# with: -# os: windows-latest -# java-version: ${{ matrix.java-version }} -# millargs: ${{ matrix.millargs }} -# -# itest: -# needs: build-linux -# strategy: -# fail-fast: false -# matrix: -# 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 -# - java-version: 17 # Have one job on default JVM -# buildcmd: ci/test-mill-bootstrap.sh -# -# uses: ./.github/workflows/post-build-raw.yml -# with: -# java-version: ${{ matrix.java-version }} -# buildcmd: ${{ matrix.buildcmd }} -# -# # Scalafmt, Mima, and Scalafix job runs last because it's the least important: -# # usually just an automated or mechanical manual fix to do before merging -# lint-autofix: -# needs: build-linux -# uses: ./.github/workflows/post-build-raw.yml -# with: -# java-version: '17' -# buildcmd: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources + __.mimaReportBinaryIssues + __.fix --check + mill.javalib.palantirformat.PalantirFormatModule/ --check + mill.kotlinlib.ktlint.KtlintModule/checkFormatAll + - java-version: 17 + millargs: "'example.scalalib.__.local.server.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'example.kotlinlib.__.local.server.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'example.android.__.local.server.test'" + install-android-sdk: true + + - java-version: 17 + millargs: "'example.{pythonlib,javascriptlib}.__.local.server.test'" + install-android-sdk: false + + - java-version: 11 + millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'" + install-android-sdk: false + + - java-version: '17' + millargs: "'example.thirdparty[arrow].local.server.test'" + install-android-sdk: false + + - java-version: 11 + millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'" + install-android-sdk: false + # Most of these integration tests should not depend on which mode they + # are run in, so just run them in `local` + - java-version: '17' + millargs: "'integration.{failure,feature,ide}.__.local.server.test'" + install-android-sdk: false + # These invalidation tests need to be exercised in both execution modes + # to make sure they work with and without -i/--no-server being passed + - java-version: 17 + millargs: "'integration.invalidation.__.packaged.fork.test'" + install-android-sdk: false + + - java-version: 17 + millargs: "'integration.invalidation.__.packaged.server.test'" + install-android-sdk: false + + # Run some smoketests with Graal native image launcher + - java-version: 17 + millargs: "'example.javalib.__.native.server.test'" + install-android-sdk: false + + - java-version: '17' + millargs: "'integration.{failure,feature,ide}.__.native.server.test'" + install-android-sdk: false + + uses: ./.github/workflows/post-build-selective.yml + with: + install-android-sdk: ${{ matrix.install-android-sdk }} + java-version: ${{ matrix.java-version }} + millargs: ${{ matrix.millargs }} + + windows: + needs: build-windows + strategy: + fail-fast: false + matrix: + include: + # just run a subset of examples/ on Windows, because for some reason running + # the whole suite can take hours on windows v.s. half an hour on linux + - java-version: 11 + millargs: '"{main,scalalib,bsp}.__.test"' + - java-version: 11 + millargs: '"example.scalalib.basic.__.packaged.fork.test"' + - java-version: 17 + millargs: "'integration.{feature,failure}.__.packaged.fork.test'" + - java-version: 11 + millargs: "'integration.invalidation.__.packaged.server.test'" + - java-version: 11 + millargs: "'integration.invalidation.__.native.server.test'" + - java-version: 11 + millargs: "contrib.__.test" + + uses: ./.github/workflows/post-build-selective.yml + with: + os: windows-latest + java-version: ${{ matrix.java-version }} + millargs: ${{ matrix.millargs }} + + itest: + needs: build-linux + strategy: + fail-fast: false + matrix: + 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 + - java-version: 17 # Have one job on default JVM + buildcmd: ci/test-mill-bootstrap.sh + + uses: ./.github/workflows/post-build-raw.yml + with: + java-version: ${{ matrix.java-version }} + buildcmd: ${{ matrix.buildcmd }} + + # Scalafmt, Mima, and Scalafix job runs last because it's the least important: + # usually just an automated or mechanical manual fix to do before merging + lint-autofix: + needs: build-linux + uses: ./.github/workflows/post-build-raw.yml + with: + java-version: '17' + buildcmd: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources + __.mimaReportBinaryIssues + __.fix --check + mill.javalib.palantirformat.PalantirFormatModule/ --check + mill.kotlinlib.ktlint.KtlintModule/checkFormatAll From d966e91637f035e75c5559fabc8368c214cc1e57 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 12:18:29 +0800 Subject: [PATCH 59/61] . --- dist/package.mill | 46 +++++++++++++++++++++++----------------- integration/package.mill | 2 +- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/dist/package.mill b/dist/package.mill index 251c6342a7a..1af49efdba4 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -8,7 +8,7 @@ import $file.ci.upload import scala.util.{Properties, Using} -object `package` extends RootModule with build.MillPublishJavaModule with mill.scalalib.NativeImageModule{ +object `package` extends RootModule with build.MillPublishJavaModule { /** * Version of [[dist]] meant for local integration testing within the Mill @@ -348,28 +348,36 @@ object `package` extends RootModule with build.MillPublishJavaModule with mill.s } } - def nativeImageExecutableName = if (Properties.isWin) "mill.exe" else "mill" - def mainClass = Some("mill.runner.client.MillClientMain") - def nativeImageClasspath = build.runner.client.runClasspath() - def nativeImage = Task { - val previous = super.nativeImage().path - val executable = Task.dest / previous.last - - Using(os.write.outputStream(executable)) { out => - out.write(os.read.bytes(previous)) - out.write(System.lineSeparator.getBytes) - out.write(os.read.bytes(assembly().path)) + object native extends build.MillPublishJavaModule with mill.scalalib.NativeImageModule { + def moduleDeps = build.dist.moduleDeps + def nativeImageExecutableName = if (Properties.isWin) "mill.exe" else "mill" + + def mainClass = Some("mill.runner.client.MillClientMain") + + def nativeImageClasspath = build.runner.client.runClasspath() + + def nativeImage = Task { + val previous = super.nativeImage().path + val executable = Task.dest / previous.last + + Using(os.write.outputStream(executable)) { out => + out.write(os.read.bytes(previous)) + out.write(System.lineSeparator.getBytes) + out.write(os.read.bytes(assembly().path)) + } + + os.perms.set(executable, "rwxrwxrwx") + PathRef(executable) } - os.perms.set(executable, "rwxrwxrwx") - PathRef(executable) - } + def jar = nativeImage() - def nativeImageOptions = Seq("--no-fallback") + def nativeImageOptions = Seq("--no-fallback") - def zincWorker = ModuleRef(ZincWorkerGraalvm) + def zincWorker = ModuleRef(ZincWorkerGraalvm) - object ZincWorkerGraalvm extends ZincWorkerModule { - def jvmId = build.Settings.graalvmJvmId + object ZincWorkerGraalvm extends ZincWorkerModule { + def jvmId = build.Settings.graalvmJvmId + } } } diff --git a/integration/package.mill b/integration/package.mill index 2dbfcfd079e..de6a6e23109 100644 --- a/integration/package.mill +++ b/integration/package.mill @@ -73,7 +73,7 @@ object `package` extends RootModule { def millIntegrationLauncher = build.dist.assembly() } object native extends IntegrationLauncherModule { - def millIntegrationLauncher = build.dist.nativeImage() + def millIntegrationLauncher = build.dist.native.nativeImage() } trait IntegrationLauncherModule extends Module { def millIntegrationLauncher: T[PathRef] From 4223880256af2db8f8029fe99bd66fee0242d0c7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 13:36:53 +0800 Subject: [PATCH 60/61] . --- .github/workflows/run-tests.yml | 2 +- dist/package.mill | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 37c3ade7b3e..4c09a372a37 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -169,7 +169,7 @@ jobs: - java-version: 11 millargs: "'integration.invalidation.__.packaged.server.test'" - java-version: 11 - millargs: "'integration.invalidation.__.native.server.test'" + millargs: "'integration.invalidation.__.packaged.server.test'" - java-version: 11 millargs: "contrib.__.test" diff --git a/dist/package.mill b/dist/package.mill index 1af49efdba4..ce87f3b1f9e 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -113,7 +113,7 @@ object `package` extends RootModule with build.MillPublishJavaModule { PathRef(Task.dest / filename) } def assembly = Task { - Task.traverse(allPublishModules)(m => m.publishLocalCached)() + Task.traverse(allPublishModules.filter(_ != native))(m => m.publishLocalCached)() val raw = rawAssembly().path os.copy(raw, Task.dest / raw.last) PathRef(Task.dest / raw.last) From 8ce70d32e3b1daaa0bc8dbb86b8762494daae243 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 9 Jan 2025 13:41:31 +0800 Subject: [PATCH 61/61] . --- dist/package.mill | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/package.mill b/dist/package.mill index ce87f3b1f9e..a37b55dc6d1 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -356,7 +356,7 @@ object `package` extends RootModule with build.MillPublishJavaModule { def nativeImageClasspath = build.runner.client.runClasspath() - def nativeImage = Task { + def rawNativeImage = Task { val previous = super.nativeImage().path val executable = Task.dest / previous.last @@ -370,7 +370,12 @@ object `package` extends RootModule with build.MillPublishJavaModule { PathRef(executable) } - def jar = nativeImage() + def nativeImage = Task { + Task.traverse(allPublishModules.filter(_ != native))(m => m.publishLocalCached)() + rawNativeImage() + } + + def jar = rawNativeImage() def nativeImageOptions = Seq("--no-fallback")