You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Respect rules_java as the source of truth for java toolchains
Context: #18373
Currently the definitions of java tools, remote JDKs, and Java toolchains are duplicated in both Bazel sources and rules_java, and they go out of sync quite often. By default, the default toolchains shipped with the Bazel binary uses the one in Bazel sources except when Bzlmod is enabled.
bazelbuild/rules_java#110 syncs java toolchain related files from Bazel sources to rules_java and this PR removes most of the definitions in Bazel source and uses rules_java as the source of truth.
Significant changes in this PR:
- Removed all java tools definitions from distdir_deps.bzl
- Removed all remote JDK definitions from distdir_deps.bzl except the ones for to be embedded within Bazel binary.
- Changed `jdk.WORKSPACE.tmpl` to load java tools and JDKs from rules_java as WORKSPACE suffix.
- Removed the `jdk_http_archives` hack for some shell tests. That dates back to #8361, I don't think it's needed since we have the WORKSPACE suffix by default.
- When building Bazel with Bazel, we were using the java toolchains shipped in `@bazel_tools` of the Bazel binary, now we use the java toolchains from the `rules_java` defined in distdir_deps.bzl. This enables us to build Bazel itself with the latest java toolchain, therefore can detect issues earlier.
- Removed `_for_testing` suffixes for the shared repo hack for Bazel CI since the java tools and remote JDKs versions we load to build Bazel are the same as the ones shipped in the Bazel binary we built (via `jdk.WORKSPACE.tmpl`) and used in the integration tests. They all come from the rules_java version in distdir_deps.bzl.
- Removed the `test_WORKSPACE_files` hack for `workspace_resolved_test.sh`.
- Mocked rules_java in some integration tests to avoid needing to download it or its transitive dependencies.
Breaking changes:
- Loading `.bzl` files under `@bazel_tools//tools/jdk` in WORKSPACE now requires you to define `rules_java` in advance, the `rules_java` definition in WORKSPACE suffix cannot guarantee `@rules_java` exist because it's appended after the content of the user WORKSPACE file.
Closes#18423.
RELNOTES[INC]: Loading `.bzl` files under `@bazel_tools//tools/jdk` in WORKSPACE now requires `rules_java` to be defined in advance.
PiperOrigin-RevId: 536682532
Change-Id: Ia7475bfe134729ab1592b0ef0a31d28eb839b5ac
0 commit comments