-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide default JVM version to be used by Mill server process, when `…
….mill-jvm-version` and system `java` are not provided (#4597) This PR makes Mill's server use a fixed JVM version by default in the case where no other Java version is available: 1. No `.mill-jvm-version` file present 2. No `java` command available environmentally 3. The Mill client has no `java.home` set (i.e. it is a graal native image) This makes running Mill on a clean environment without a JVM installed work by default. Previously, it either needed you to define a `.mill-jvm-version` or install a JVM, either of which is a manual step we now can now avoid. Now it instead uses the version of Java configured in Mill's own `.mill-jvm-version` file We still allow any system `java` command to take precedence over the default, since that's what most people would expect when using the JVM. Added an integration test in CI `no-jvm-bootstrap` that runs Mill with the native launcher with no `.mill-jvm-version` file and no system `java` installed to verify that it falls back to the Mill default JVM version. Needed to add some hacky test hooks to make sure we exercise the code path in question
- Loading branch information
Showing
18 changed files
with
159 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
zulu:17.0.13 | ||
zulu:17.0.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
integration/bootstrap/no-java-bootstrap/resources/bar/src/bar/Bar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package bar; | ||
public class Bar { | ||
public static void main(String[] args) { | ||
System.out.println("Hello World! " + System.getProperty("java.version")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package build | ||
import mill._, javalib._ | ||
|
||
def foo = Task { | ||
println(System.getProperty("java.version")) | ||
} | ||
|
||
object bar extends JavaModule |
39 changes: 39 additions & 0 deletions
39
integration/bootstrap/no-java-bootstrap/src/NoJavaBootstrapTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package mill.integration | ||
|
||
import mill.testkit.UtestIntegrationTestSuite | ||
|
||
import utest._ | ||
|
||
object NoJavaBootstrapTests extends UtestIntegrationTestSuite { | ||
// Don't propagate `JAVA_HOME` to this test suite, because we want to exercise | ||
// the code path where `JAVA_HOME` is not present during bootstrapping | ||
override def propagateJavaHome = false | ||
val tests: Tests = Tests { | ||
test - integrationTest { tester => | ||
import tester._ | ||
os.remove(tester.workspacePath / ".mill-jvm-version") | ||
// The Mill server process should use the default Mill Java version, | ||
// even without the `.mill-jvm-version` present | ||
// | ||
// Force Mill client to ignore any system `java` installation, to make sure | ||
// this tests works reliably regardless of what is installed on the system | ||
val res1 = eval( | ||
"foo", | ||
env = Map("MILL_TEST_SUITE_IGNORE_SYSTEM_JAVA" -> "true"), | ||
stderr = os.Inherit | ||
) | ||
|
||
assert(res1.out == System.getProperty("java.version")) | ||
|
||
// Any `JavaModule`s run from the Mill server should also inherit | ||
// the default Mill Java version from it | ||
val res2 = eval( | ||
"bar.run", | ||
env = Map("MILL_TEST_SUITE_IGNORE_SYSTEM_JAVA" -> "true"), | ||
stderr = os.Inherit | ||
) | ||
|
||
assert(res2.out == s"Hello World! ${System.getProperty("java.version")}") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.