Run rules_jvm_external jar tools with exec Java#30147
Conversation
Invoke AddJarManifestEntry_deploy.jar with current_java_runtime in the exec configuration instead of executing the AddJarManifestEntry java_binary launcher. This preserves --tool_java_runtime_version and selects Java for the execution platform when the target and execution architectures differ. Treat AddJarManifestEntry_deploy.jar and JavaRuntimeInfo.files as action tools, and preserve the AddJarManifestEntry -XX:-UsePerfData JVM flag. Use local_jdk for bootstrap Java runtimes so the offline source distribution build does not download remote JDK 21 archives after jvm_import begins using current_java_runtime. Test: bazel test //src/test/shell/bazel:bazel_bootstrap_distfile_test
fmeum
left a comment
There was a problem hiding this comment.
This looks good to me, but I would like to understand better why the changes result in the bootstrap build fetching a remotejdk when it previously didn't. Could you explain this in more detail in the PR description?
|
|
||
| : ${JAVA_VERSION:="21"} | ||
|
|
||
| # The bootstrap runs offline and already requires JAVA_HOME, so use the local JDK for Java actions. |
There was a problem hiding this comment.
This should already be the case. Do you know what's going wrong?
There was a problem hiding this comment.
JAVA_HOME already supplies the JDK used by scripts/bootstrap/BUILD.bootstrap, but the new @rules_java//toolchains:current_java_runtime dependency performs separate Java runtime toolchain resolution. The existing --java_runtime_version=21 and --tool_java_runtime_version=21 select local_jdk only when JAVA_HOME contains JDK 21. The bootstrap accepts any JDK >= 21, so with JDK 25 I reproduced toolchain resolution rejecting @@rules_java++toolchains+local_jdk//:runtime_toolchain_definition because its detected version is 25 and selecting @@rules_java++toolchains+remotejdk21_macos_aarch64//:jdk instead. That repository is intentionally absent from the offline bootstrap repository cache, so the nested bootstrap tries to download it and fails.
Selecting local_jdk by name makes both runtime selectors use JAVA_HOME regardless of its newer major version. The Java language selectors remain 21, and scripts/bootstrap/compile.sh checks that JAVA_HOME is at least that version. I also verified the inverse toolchain result: with both runtime selectors set to local_jdk, the JDK 25 run selects @@rules_java++toolchains+local_jdk//:jdk.
-zbarskybot
There was a problem hiding this comment.
This reasoning does not sound right to me. I'll look further into this and report back.
There was a problem hiding this comment.
#30106 also runs into similar issues. It would be great to have more direct (in particular, early) checks for the expected host-provided dependencies of the bootstrap build.
hvadehra
left a comment
There was a problem hiding this comment.
Can you try running //src/test/shell/bazel:bazel_determinism_test on this as well?
|
|
||
| : ${JAVA_VERSION:="21"} | ||
|
|
||
| # The bootstrap runs offline and already requires JAVA_HOME, so use the local JDK for Java actions. |
There was a problem hiding this comment.
This reasoning does not sound right to me. I'll look further into this and report back.
|
Confirmed at I ran the test action locally and disabled the test harness's forced IPv6 preference because this host advertises an IPv6 default route but cannot reach -zbarskybot |
Summary
rules_jvm_external6.8 sojvm_importrunsAddJarManifestEntry_deploy.jarwithcurrent_java_runtimein the exec configurationlocal_jdkfor bootstrap Java runtimes so the offline source distribution build does not fetch remote JDK 21 archivesMODULE.bazel.lockMotivation
This replaces #29764, which was erased from
masterafter an accidental GitHub merge. Invoking the deploy JAR throughcurrent_java_runtimeavoids executing the generated Bash launcher on a Windows host with Linux remote execution. The new runtime dependency made//src/test/shell/bazel:bazel_bootstrap_distfile_testresolveremotejdk21_*, which is intentionally absent from the offline distribution repository cache; the bootstrap already requiresJAVA_HOME, so selectinglocal_jdkkeeps the bootstrap offline while retaining Java language level 21.The corresponding upstream change is bazel-contrib/rules_jvm_external#1583.
Validation
bazel test //src/test/shell/bazel:bazel_bootstrap_distfile_testwith JDK 21 (passed in 1671.2s)bazel mod deps --lockfile_mode=errorbash -n scripts/bootstrap/bootstrap.sh