简体   繁体   中英

How to build and run using an up-to-date version of JDK?

Bazel is downloading and using an old Java 11.0.1. There have been five releases of Java 11 with security updates since then.

I can make Bazel use my local JDK but this has obvious drawbacks.

How can I build using a safe up-to-date version of JDK?

I am not at all convinced that this is necessary. (See my comments on the question.)

However if you really wanted to change Bazel's built-in Java you could take one of these approaches:

  1. Follow the instructions in the Contributing to Bazel page. Note that you need to install Bazel to build Bazel. I am assuming that you get to choose (somehow) the Java that gets embedded in the "distributable" ... or that is downloaded by it, if that is what is happening.
  2. There is a "compile.sh" file that might be an alternative. (I didn't look too hard at it.)
  3. You could probably download and install Bazel in the normal way and tweak the installation to replace the embedded Java with whatever you want. For instance, try replacing its internal Java installation tree with a symlink to your system Java install that is kept up-to-date using the Linux package manager.

There is a --javabse option in Bazel 2.0.0 (and also some other Bazel versions):

--javabase (label) This option sets the label of the base Java installation to use for bazel run, bazel test, and for Java binaries built by java_binary and java_test rules.

Just add a .bazelrc file alongside to your WORKSPACE file:

.bazelrc

build --javabase=//my_tools/my_own_jdk

Take also a look onto java_runtime()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM