Fix WORKSPACE build after upgrading rules_java to 8.16.1
rules_java 8.16.1 added a top-level `load("@bazel_features//private:util.bzl")`
to rules_java_deps.bzl, so in WORKSPACE mode @bazel_features must be defined
before that file is loaded. Declaring it (mirroring rules_java's own WORKSPACE)
then surfaces a Bazel 8 autoload cycle on @@bazel_features_version//:version.bzl
(bazelbuild/bazel#23043), which is excluded via --repositories_without_autoloads.
Also bump the published example/snippet to 8.16.1 with the same setup and
document the Bazel 8 flag in the release notes.
Compatibility:
- bzlmod consumers (BCR path): unaffected by these files; they pick up
rules_java >= 8.16.1 + bazel_features 1.30.0 transitively via MVS.
compatibility_level is unchanged (1). Verified //bazel:android-all builds
in bzlmod on Bazel 8.2.1 (cold, no flag) and 9.1.1 -- the autoload cycle is
WORKSPACE-only, so the .bazelrc flag does not need to ship.
- WORKSPACE consumers: the published snippet now uses 8.16.1. Bazel 8 users
must add the documented --repositories_without_autoloads flag to their own
.bazelrc (it is not shipped with a release). Verified the example's
//:SparseArraySetTest passes on Bazel 7.4.1 in WORKSPACE mode.
- The flag exists and is accepted on Bazel 7.4.1 / 8.2.1 / 9.0.0 / 9.1.1, and
is a no-op on Bazel 7 and 9 (autoloads default to empty there).
This project provides build rules for integrating Robolectric into Bazel projects.
Follow instructions in the release notes from the release you use: https://github.com/robolectric/robolectric-bazel/releases
In your android_local_test targets in the BUILD files, depend on the Robolectric targets @maven//:org_robolectric_robolectric and @robolectric//bazel:android-all:
android_local_test( name = "greeter_activity_test", srcs = ["GreeterTest.java"], manifest = "TestManifest.xml", test_class = "com.example.bazel.GreeterTest", deps = [ ":greeter_activity", "@maven//:org_robolectric_robolectric", "@robolectric//bazel:android-all", ], )
update-versions.py walks org.robolectric:android-all-instrumented on Maven Central and rewrites bazel/robolectric.bzl in place: it bumps the version and sha256 of any Android API group that has a newer release, and inserts new entries for any numeric API newer than the highest one currently listed.
./update-versions.py # apply updates ./update-versions.py --dry-run # preview without writing
A new release can be published by just pushing a tag.
Once the tag is pushed, GitHub Actions will build, test, and publish a release to both GitHub releases and the BCR.
Example:
git tag 4.11.1 git push origin 4.11.1