bazelbuild / bazel-toolchains

Repository that hosts Bazel toolchain configs for remote execution and related support tools.
Apache License 2.0
185 stars 96 forks source link

rbe_configs_gen: no native support for Java 11 runtime #961

Open davido opened 3 years ago

davido commented 3 years ago

I'm trying to migrate from bazel-toolchain 5.0.0 to 5.1.0, where support for rbe_autoconfig was discontinued.

In bazel-toolchain 5.0.0 I used this code to build against JDK 11:

http_archive(
    name = "bazel_toolchains",
    sha256 = 1adf7a8e9901287c644dcf9ca08dd8d67a69df94bedbd57a841490a84dc1e9ed",
    strip_prefix = "bazel-toolchains-5.0.0",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/v5.0.0.tar.gz",
        "https://github.com/bazelbuild/bazel-toolchains/archive/v5.0.0.tar.gz",
    ],
)

load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")

# Creates a default toolchain config for RBE.
rbe_autoconfig(
    name = "rbe_jdk11",
    java_home = "/usr/lib/jvm/11.29.3-ca-jdk11.0.2/reduced",
    use_checked_in_confs = "Force",
)

After migration to generated RBE configuration, that I produced with this command:

  $ ./rbe_configs_gen \
  --bazel_version=4.1.0 \
  --toolchain_container=l.gcr.io/google/rbe-ubuntu18-04:latest \
  --output_src_root=/home/davido/projects/gerrit \
  --output_config_path=tools/rbe \
  --exec_os=linux \
  --target_os=linux

native support for JDK 11 is gone.

I have to manually mess around with generated tools/rbe/java/BUILD file and add this section:

java_runtime(
    name = "jdk11",
    srcs = [],
    java_home = "/usr/lib/jvm/11.29.3-ca-jdk11.0.2/reduced",
)

It would be great if this would be supported and I wouldn't need to manipulate generated Starlark files.

May be add these options: --java_runtime_additional_name=jdk11 --java_runtime_additional_home=/usr/lib/jvm/11.29.3-ca-jdk11.0.2/reduced.

See also this discussion.

sgammon commented 1 year ago

hello from 2022, nearly 2023. java 20 is out, so is bazel 6. still hitting this