-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide default JVM version to be used by Mill server process, when .mill-jvm-version
and system java
are not provided
#4597
Conversation
Path millJvmVersionFile = millJvmVersionFile(); | ||
|
||
String javaHome = null; | ||
if (Files.exists(millJvmVersionFile)) { | ||
jvmId = Files.readString(millJvmVersionFile).trim(); | ||
if (jvmId.equals("global")) jvmId = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI in coursier, system
stands for "use the already installed / available JVM". Don't know which is better, if global
feels natural to enough people, I could accept it in coursier too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
system
works too, I was unaware of Coursier's default. I can change this over
Path millJvmVersionFile = millJvmVersionFile(); | ||
|
||
String javaHome = null; | ||
if (Files.exists(millJvmVersionFile)) { | ||
jvmId = Files.readString(millJvmVersionFile).trim(); | ||
if (jvmId.equals("global")) jvmId = null; | ||
} else { | ||
jvmId = "zulu:17.0.3"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use zulu
rather than temurin
? I recall defaulting to zulu
sometimes, because it has JDK 8 builds for macOS ARM64 while temurin
doesn't, but that shouldn't be a problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC there were some JDKs that Zulu had published for Windows-ARM that Temurin hadn't for these versions, which is why we use Zulu in Mill's own config. But probably can find a version that works on Termurin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the issue: Temurin doesn't publish JDKs for versions <21 on Windows-ARM (e.g. my Surface Laptop 7). The only options for JDK 17 on Windows-ARM are Liberica and Zulu
.mill-jvm-version
containing global
.mill-jvm-version
containing system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
.mill-jvm-version
containing system
.mill-jvm-version
containing system
Seems like CI is hitting |
Not 100% sure, but I suspect the way the coursier archive cache is handled on CI might cause that. IIUC, things like this then this make the |
Going to try to tweak how |
Good catch with the |
645065b
to
7882e6d
Compare
Let me see if setting the default in github actions to |
.mill-jvm-version
containing system
.mill-jvm-version
containing system
Looks like passing in |
Seems like setting |
One possible point of confusion with this PR if you use Mill without configuring a java version on your This would be pretty confusing, and maybe in the absence of explicit configuration it's worth making application code build/run/tested with mill default to the system In general it seems reasonable that the default JVM for user-code and for I think the right thing to do here may be to separate the two:
I expect most people who want to tweak the Java version would care about However, the downside here is that someone would need to download two separate JVMs just to build their code. While the download is automatic, the user would still need to wait for it to complete, which might be slow since JVMs are big |
Another more lightweight change would be to only fall back to the hardcoded I'm not sure how to check whether there is already a JVM available, apart from shelling out to |
Both coursier and Scala CLI do such things. I can't have a look right now, but IIRC, they might just look at |
coursier and Scala CLI don't require a minimum Java version (they do, like >= 8, but don't really check it IIRC), but Scala CLI does look at the Java version when it spawns a Bloop server (it needs >= 17). |
05a229f
to
a286d19
Compare
90e5a23
to
de7c1d7
Compare
f7a0d41
to
de8a343
Compare
Decided to go with the more conservative approach of just providing a fallback default if there is no JVM available. |
This PR makes Mill's server use a fixed JVM version by default in the case where no other Java version is available:
.mill-jvm-version
file presentjava
command available environmentallyjava.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
fileWe 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 systemjava
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