Skip to content

How to prevent bazel from downloading JDK11 and JDK21? #21752

Answered by hvadehra
jason-sachs asked this question in Q&A
Discussion options

You must be logged in to vote

Yes.

Forcing the use of only the local jdk involves two things:

  1. The default target java_runtime is local_jdk but the default execution java_runtime is remotejdk_11. To use the local jdk for execution, use --tool_java_runtime_version=local_jdk

  2. If a project does nothing wrt java toolchains in MODULE.bazel / WORKSPACE, the rules_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 (in MODULE.bazel / WORKSPACE). Alternatively, use --extra_toolchains=@local_jdk//:all

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@stagnation
Comment options

Answer selected by meteorcloudy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants