Skip to content

use DefaultInfo in rules_java #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

dws
Copy link
Contributor

@dws dws commented Jun 11, 2025

We here address the following obstacles in rules_java to using Bazel's
--incompatible_disable_target_default_provider_fields flag:

ERROR: /private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/toolchains/BUILD:359:27: in java_toolchain rule @@rules_java+//toolchains:toolchain_jdk_21:
Traceback (most recent call last):
        File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/java_toolchain.bzl", line 100, column 45, in _java_toolchain_impl
                jacocorunner = ctx.attr.jacocorunner.files_to_run if ctx.attr.jacocorunner else None,
Error: Accessing the default provider in this manner is deprecated and will be removed soon. It may be temporarily re-enabled by setting --incompatible_disable_target_default_provider_fields=false. See https://github.com/bazelbuild/bazel/issues/20183 for details.
ERROR: /private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/toolchains/BUILD:359:27: Analysis of target '@@rules_java+//toolchains:toolchain_jdk_21' failed
ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis failed

ERROR: /Users/dws/src/bazel-dws/third_party/BUILD:578:20: in java_import rule //third_party:netty_tcnative_checked_in:
Traceback (most recent call last):
        File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/bazel/rules/bazel_java_import.bzl", line 25, column 34, in _proxy
                return bazel_java_import_rule(
        File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/impl/bazel_java_import_impl.bzl", line 132, column 35, in bazel_java_import_rule
                collected_jars = _collect_jars(ctx, jars)
        File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/impl/bazel_java_import_impl.bzl", line 38, column 24, in _collect_jars
                for jar in info.files.to_list():
Error: Accessing the default provider in this manner is deprecated and will be removed soon. It may be temporarily re-enabled by setting --incompatible_disable_target_default_provider_fields=false. See https://github.com/bazelbuild/bazel/issues/20183 for details.
ERROR: /Users/dws/src/bazel-dws/third_party/BUILD:578:20: Analysis of target '//third_party:netty_tcnative_checked_in' failed
ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis failed

We here address the following obstacles in rules_java to using
Bazel's --incompatible_disable_target_default_provider_fields flag:

    ERROR: /private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/toolchains/BUILD:359:27: in java_toolchain rule @@rules_java+//toolchains:toolchain_jdk_21:
    Traceback (most recent call last):
            File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/java_toolchain.bzl", line 100, column 45, in _java_toolchain_impl
                    jacocorunner = ctx.attr.jacocorunner.files_to_run if ctx.attr.jacocorunner else None,
    Error: Accessing the default provider in this manner is deprecated and will be removed soon. It may be temporarily re-enabled by setting --incompatible_disable_target_default_provider_fields=false. See bazelbuild/bazel#20183 for details.
    ERROR: /private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/toolchains/BUILD:359:27: Analysis of target '@@rules_java+//toolchains:toolchain_jdk_21' failed
    ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis failed

    ERROR: /Users/dws/src/bazel-dws/third_party/BUILD:578:20: in java_import rule //third_party:netty_tcnative_checked_in:
    Traceback (most recent call last):
            File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/bazel/rules/bazel_java_import.bzl", line 25, column 34, in _proxy
                    return bazel_java_import_rule(
            File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/impl/bazel_java_import_impl.bzl", line 132, column 35, in bazel_java_import_rule
                    collected_jars = _collect_jars(ctx, jars)
            File "/private/var/tmp/_bazel_dws/7fd3cd5077fbf76d9e2ae421c39ef7ed/external/rules_java+/java/common/rules/impl/bazel_java_import_impl.bzl", line 38, column 24, in _collect_jars
                    for jar in info.files.to_list():
    Error: Accessing the default provider in this manner is deprecated and will be removed soon. It may be temporarily re-enabled by setting --incompatible_disable_target_default_provider_fields=false. See bazelbuild/bazel#20183 for details.
    ERROR: /Users/dws/src/bazel-dws/third_party/BUILD:578:20: Analysis of target '//third_party:netty_tcnative_checked_in' failed
    ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis failed
@dws dws marked this pull request as ready for review June 11, 2025 21:51
@dws dws requested review from comius and a team as code owners June 11, 2025 21:51
Copy link
Member

@hvadehra hvadehra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

copybara-service bot pushed a commit to bazelbuild/bazel that referenced this pull request Jun 17, 2025
…der_fields

We here address obstacles to building Bazel with `--incompatible_disable_target_default_provider_fields` enabled.

This includes patches representing

- bazelbuild/apple_support#413
- bazelbuild/rules_java#303
- grpc/grpc-java#12148

which should be removed once these PRs have been included in releases of their respective repos.  All of these pull requests have been approved and merged into their respective repositories.

Once #26276 is cherry-picked into a Bazel 8 release, we should be able to update `.bazelversion` to that release, and in conjunction with the changes herein, we should be able to enable  `--incompatible_disable_target_default_provider_fields` in `.bazelrc` in order to prevent regressions.  Ideally, we could also flip the default value of this flag once #26297 also lands.
Note that #26293 is related, but not strictly needed for builds.

Closes #26272.

PiperOrigin-RevId: 772542631
Change-Id: Ib5db3ffa3f4857199a6f8d838078d7ced2281ba3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants