Skip to content

incompatible_use_toolchain_providers_in_java_common: pass JavaToolchainInfo and JavaRuntimeInfo providers to java_common APIs instead of configured targets #7186

@cushon

Description

@cushon

The option --incompatible_use_toolchain_providers_in_java_common makes java_toolchain and host_javabase APIs in java_common accept the java_common.JavaToolchainInfo and java_common.JavaRuntimeInfo providers instead of configured targets.

This change is being made in preparation for migrating the Java to use Toolchain Resolution (#4592).

Migration Notes

Update all java_common APIs with the parameters java_toolchain or host_javabase to use the find_java_runtime_toolchain and find_java_toolchain utilities:

+@load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_runtime_toolchain", "find_java_toolchain")

java_common.compile(
  ...,
-  java_toolchain = ctx.attr._java_toolchain,
-  host_javabase = ctx.attr._host_javabase,
+  java_toolchain = find_java_toolchain(ctx, ctx.attr._java_toolchain),
+  host_javabase = find_java_runtime_toolchain(ctx, ctx.attr._host_javabase),
)

The ctx and java_toolchain_attr parameters of java_common.default_javac_opts have been replaced with java_toolchain:

+@load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_toolchain")

javacopts = java_common.default_javac_opts(
-    ctx,
-    java_toolchain_attr = "_java_toolchain",
+    find_java_toolchain(ctx, ctx.attr._java_toolchain),
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions