Skip to content

Commit

Permalink
Expose vanilla java toolchain
Browse files Browse the repository at this point in the history
To use the latest supported language level from the --host_javabase, use
VanillaJavaBuilder (which should work with most host JDKs) and leave the
source/target/bootclasspath unset so they default to the latest
supported versions.

With this in place, new java_runtime can be used, e.g.:

  java_runtime(
      name = "jdk11",
      java_home = "/usr/lib64/jvm/java-11",
      visibility = ["//visibility:public"],
  )

Now the JDK11 can be used with the language level 11:

  $ bazel build --host_javabase=:jdk11 \
    --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
    --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
    :a

Related: #5723

Closes #5984.

PiperOrigin-RevId: 213859466
  • Loading branch information
davido authored and Copybara-Service committed Sep 20, 2018
1 parent 6df2a74 commit 0bef68e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,27 @@ alias(
actual = "toolchain_java8",
)

# The 'vanilla' toolchain is an unsupported alternative to the default.
#
# It does not provider any of the following features:
# * Error Prone
# * Strict Java Deps
# * Header Compilation
# * Reduced Classpath Optimization
#
# It uses the version of javac from the `--host_javabase` instead of the
# embedded javac, which may not be source- or bug-compatible with the embedded
# javac.
#
# However it does allow using a wider range of `--host_javabase`s, including
# versions newer than the current embedded JDK.
default_java_toolchain(
name = "toolchain_vanilla",
forcibly_disable_header_compilation = True,
javabuilder = [":vanillajavabuilder"],
jvm_opts = [],
)

[
default_java_toolchain(
name = "toolchain_java%d" % release,
Expand Down

0 comments on commit 0bef68e

Please sign in to comment.