How to prevent bazel from downloading JDK11 and JDK21? #21752
-
We're using JDK8u152 for licensing reasons, but when I follow the Java tutorial (https://bazel.build/start/java) and set JAVA_HOME to point to my installed JDK, when I How do I prevent this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
/cc @hvadehra Is this expected behaviour? |
Beta Was this translation helpful? Give feedback.
-
Yes. Forcing the use of only the local jdk involves two things:
|
Beta Was this translation helpful? Give feedback.
Yes.
Forcing the use of only the local jdk involves two things:
The default target
java_runtime
islocal_jdk
but the default executionjava_runtime
isremotejdk_11
. To use the local jdk for execution, use--tool_java_runtime_version=local_jdk
If a project does nothing wrt java toolchains in
MODULE.bazel
/WORKSPACE
, therules_java
order of registration will be followed where we register the remote jdks before the local one, so those "win" by default. The way to avoid this is to explicitly register the local jdk toolchain first for the project (inMODULE.bazel
/WORKSPACE
). Alternatively, use--extra_toolchains=@local_jdk//:all