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).
5 files changed
tree: 83dc985b7fdbc09c95e36688a96517ad2f93777c
  1. .bcr/
  2. .github/
  3. bazel/
  4. examples/
  5. tests/
  6. .bazelignore
  7. .bazelrc
  8. .bazelversion
  9. .gitignore
  10. BUILD.bazel
  11. CONTRIBUTING.md
  12. LICENSE
  13. MODULE.bazel
  14. README.md
  15. renovate.json
  16. update_versions.py
  17. WORKSPACE
  18. WORKSPACE.bzlmod
README.md

robolectric-bazel

This project provides build rules for integrating Robolectric into Bazel projects.

Releases


Installation

Follow instructions in the release notes from the release you use: https://github.com/robolectric/robolectric-bazel/releases

Usage

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",
    ],
)

Updating Android Versions

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

Publishing Releases

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