commit | 1a2c184bfc9423ea236db869841291de3be2f0da | [log] [tgz] |
---|---|---|
author | David Sanderson <32687193+dws@users.noreply.github.com> | Thu Jun 12 07:49:41 2025 -0700 |
committer | rules_java Copybara <noreply@google.com> | Thu Jun 12 07:50:14 2025 -0700 |
tree | 547c33dcffb403aa14fea60a583104ac30b7c690 | |
parent | 1947744286abd43834fd1c2a3c5a6b7495a669d5 [diff] |
use DefaultInfo in rules_java (#303) 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 Closes #303 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_java/pull/303 from dws:DefaultInfo c02b7724a5dcf85bb9c87bc06c1cd0504c0507f9 PiperOrigin-RevId: 770652076 Change-Id: Icc8a698ac66d76b47d9793a0c448d98d05e7186f
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