IMPORTANT: Bazel 8 users still using WORKSPACE please note the change in the setup below.
Changes since 8.11.0
808f8496a00a153840025a549b51d99bba874565 Use the launcher_maker
toolchain if available (#294)
042e9a629ca2cab8b13539aeaee055a9e7394fd8 Use @platforms//host
instead of @local_config_platform
4ce6ca94017971b4877a08fe178b005972d6a15b Validate java_common.compile(strict_deps)
in Starlark
94426d158cdc6fdfcba524ff042bf8ffddf9514a Fix case handling of java_common.compile(strict_deps)
1d2eecd61d1af30d70ec183c997c04eb82af32dc Remove support for empty jars attribute from java_import
86962f9c8ed73de61154e257626771c8e5df5451 Change deprecation message to be more helpful for java_proto_library/java_lite_proto_library
9fac3acdcb688d3e59ce99093749d51cacad08f4 Configure coverage helpers for the test exec group (#292)
4b5e2a936889ca423530a14afee68046918ad4b0 Fix empty jars check for Bazel java_import
ad510edc8012877fd0fd7325093855c0401c9738 Remove usages of --incompatible_disable_non_executable_java_binary
277957425bf7a7116da87709b4dc7df4441b377c The test_class
of a java_test
for JUnit4 does not have to have @RunWith
.
bf2fb4317a4d0f4e59759fc83e8208ab71e3c3e3 Fix comment
da9eee279c1f95822ad4bd3d624cceb3910f986b Fix classpath separator when cross-compiling from Windows to Unix (#290)
bd9c5f8678ad149db90ee349a6a4c3dafb9212b4 Change type of output_licenses
from attr.license
to attr.string_list
.
804e93e70f610a900b55af9208a3ba86fa5f5fcc Update to java_tools
v14.0
(#286)
05ee69248c4ac3014399fbcc4052f9c17497ba2e Add ppc64le platform support (#274)
1b5a8b24a7d87298fdaeb5e28a8d84c1c2337d82 Set use_default_shell_env = True consistently. (#276)
MODULE.bazel setup
bazel_dep(name = "rules_java", version = "8.12.0")
WORKSPACE setup
With Bazel 8.0.0 and before 8.3.0, add the following to your file:
# https://github.com/bazelbuild/bazel/pull/26119
common --repositories_without_autoloads=bazel_features_version,bazel_features_globals
In all cases, add the following to your file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/8.12.0/rules_java-8.12.0.tar.gz",
],
sha256 = "1558508fc6c348d7f99477bd21681e5746936f15f0436b5f4233e30832a590f9",
)
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()
# note that the following line is what is minimally required from protobuf for the java rules
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility
proto_bazel_features(name = "proto_bazel_features")
# register toolchains
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
rules_java_toolchains()
Using the rules
See the source.