Add `incompatible_language_version_bootclasspath` flag

Copybara Import from https://github.com/bazelbuild/rules_java/pull/182

BEGIN_PUBLIC
Add `incompatible_language_version_bootclasspath` flag (#182)

With `--@rules_java//java:incompatible_language_version_bootclasspath`, the bootclasspath used for Java compilation is now determined based on the numeric version specified in `--java_language_version` and the type specified in `--java_runtime_version` rather than just using the target runtime.

For example, with `--java_language_version=8` and
`--java_runtime_version=remotejdk_21`, the bootclasspath would be extracted from `remotejdk_8`.

For unversioned runtime versions such as `local_jdk`, the behavior doesn't change.

If a matching runtime is not available, analysis fails with a customized error message explaining the various options to the user.

Work towards https://github.com/bazelbuild/bazel/discussions/21769

Closes #182
END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_java/pull/182 from fmeum:java-language-version de275069b6c98919264f2bfce791dde56eaefcde
PiperOrigin-RevId: 703396804
Change-Id: Ieb1def97a5eee59763336eb61deaf584f341a1d4
4 files changed
tree: 17a5327514e85586e59bf3c51342fe2c78a0b3a4
  1. .bazel_checkout/
  2. .bazelci/
  3. .bcr/
  4. .github/
  5. distro/
  6. examples/
  7. java/
  8. test/
  9. toolchains/
  10. .bazelignore
  11. .bazelrc
  12. .gitignore
  13. AUTHORS
  14. BUILD
  15. CODEOWNERS
  16. CONTRIBUTING.md
  17. LICENSE
  18. MODULE.bazel
  19. README.md
  20. renovate.json
  21. WORKSPACE
  22. WORKSPACE.bzlmod
README.md

rules_java

  • Postsubmit Build status
  • Postsubmit + Current Bazel Incompatible Flags Build status

Java Rules for Bazel https://bazel.build.

Documentation

For a quickstart tutorial, see https://bazel.build/start/java

For slightly more advanced usage, like setting up toolchains or writing your own java-like rules, see https://bazel.build/docs/bazel-and-java

Core Java rules

Add a load like:

load("@rules_java//java:java_library.bzl", "java_library")

to your BUILD / BUILD.bazel / bzl` files

For detailed docs on the core rules, see https://bazel.build/reference/be/java