Use toolchain resolution in find_java_toolchain if --experimental_use_toolchain_resolution_for_java_rules is set
and return a provider instead of configured target for the legacy path.
PiperOrigin-RevId: 234061864
diff --git a/tools/jdk/toolchain_utils.bzl b/tools/jdk/toolchain_utils.bzl
index 5150cb2..adcc266 100644
--- a/tools/jdk/toolchain_utils.bzl
+++ b/tools/jdk/toolchain_utils.bzl
@@ -34,12 +34,10 @@
A JavaToolchainInfo.
"""
- _ignore = [ctx]
+ if java_common.is_java_toolchain_resolution_enabled_do_not_use(ctx = ctx):
+ return ctx.toolchains["@bazel_tools//tools/jdk:toolchain_type"]
- # TODO(b/122482627): implement toolcahin resolution for Java
- # see https://github.com/bazelbuild/bazel/issues/6521
-
- return target
+ return target[java_common.JavaToolchainInfo]
def find_java_runtime_toolchain(ctx, target):
"""
@@ -56,9 +54,7 @@
A JavaRuntimeInfo.
"""
- _ignore = [ctx]
+ if java_common.is_java_toolchain_resolution_enabled_do_not_use(ctx = ctx):
+ return ctx.toolchains["@bazel_tools//tools/jdk:runtime_toolchain_type"]
- # TODO(b/122482627): implement toolcahin resolution for Java
- # see https://github.com/bazelbuild/bazel/issues/6521
-
- return target
+ return target[java_common.JavaRuntimeInfo]