Skip to content

Bazel 9 compatibility - #108

Open
bpalermo wants to merge 1 commit into
griffinbank:mainfrom
bpalermo:bazel-9-compat
Open

Bazel 9 compatibility#108
bpalermo wants to merge 1 commit into
griffinbank:mainfrom
bpalermo:bazel-9-compat

Conversation

@bpalermo

@bpalermo bpalermo commented Aug 9, 2026

Copy link
Copy Markdown

rules_clojure does not load at all on Bazel 9. There are three separate failures, each only visible once the previous one is fixed:

name 'JavaInfo' is not defined
no such attribute 'main_class' in 'java_binary' rule
no such attribute 'runtime_deps' in 'java_test' rule

Bazel 9 removed JavaInfo and java_common from the Starlark globals, and reduced the native java_* rules to stubs with a much smaller attribute set.

Fixing the first alone isn't enough. The BUILD files in this repo use the native java_binary/java_library (second error), and clojure_binary/clojure_test are macros over native.java_binary/native.java_test (third) — so a consumer who loads java_* correctly in their own BUILD files still fails inside the macros.

What changed

Mechanical — load() additions only, no logic changes:

  • rules.bzl, rules/{jar,namespace,repl}.bzl — load JavaInfo (15 uses) and java_common (1) from rules_java.
  • rules.bzlclojure_binary/clojure_test call the rules_java java_binary/java_test rather than the natives.
  • BUILD, src/rules_clojure/BUILD, test/rules_clojure/BUILD and the three example BUILD files — load java_* from rules_java.
  • MODULE.bazelrules_java 8.16.1 → 9.7.1, which is what exposes the java/common:* load paths used above.
  • examples/simple/MODULE.bazel — declares rules_java as well. It's a separate module, so the root repo's bazel_dep isn't visible to it and its BUILD files can't resolve @rules_java without this.

Not a breaking change

bazel test //... in this repo passes 5/5 on Bazel 9.2.0 and 5/5 on Bazel 8.x. Existing users are unaffected; Bazel 9 users get a build that previously didn't load.

Also tested against a real consumer

A four-module Clojure/gRPC project using clojure_library, clojure_test and clojure_binary across 12 Bazel targets — green on Bazel 9.2.0 on both a developer machine and Linux CI.

Happy to split this into three commits by failure mode if you'd prefer, or to adjust the rules_java version if you'd rather pin lower — I picked 9.7.1 because it's current, but the change only needs whatever version first exposes java/common:java_info.bzl.

rules_clojure does not load at all on Bazel 9. Three separate failures,
each only visible once the previous one is fixed:

  1. name 'JavaInfo' is not defined
  2. no such attribute 'main_class' in 'java_binary' rule
  3. no such attribute 'runtime_deps' in 'java_test' rule

Bazel 9 removed JavaInfo and java_common from the Starlark globals, and
reduced the native java_* rules to stubs with a much smaller attribute
set. Fixing (1) alone is not enough: the BUILD files in this repo use
the native java_binary/java_library (2), and clojure_binary and
clojure_test are macros over native.java_binary/native.java_test (3),
so consumers loading java_* correctly still fail inside the macros.

This change is mechanical — load() additions only, no logic changes:

  - rules.bzl, rules/{jar,namespace,repl}.bzl: load JavaInfo (15 uses)
    and java_common (1) from rules_java.
  - rules.bzl: clojure_binary/clojure_test call the rules_java
    java_binary/java_test instead of the natives.
  - BUILD, src/rules_clojure/BUILD, test/rules_clojure/BUILD and the
    three example BUILD files: load java_* from rules_java.
  - MODULE.bazel: rules_java 8.16.1 -> 9.7.1, which is what exposes the
    java/common:* load paths used above.
  - examples/simple/MODULE.bazel: declares rules_java too. It is a
    separate module, so the root repo's bazel_dep is not visible to it
    and its BUILD files cannot resolve @rules_java without this.

Not a breaking change. `bazel test //...` in this repo passes 5/5 on
BOTH Bazel 9.2.0 and Bazel 8.x, so existing users are unaffected.

Tested with a real consumer as well as the examples here — a four-module
Clojure/gRPC project using clojure_library, clojure_test and
clojure_binary across 12 Bazel targets, green on Bazel 9.2.0 on both a
developer machine and Linux CI.
@bpalermo

Copy link
Copy Markdown
Author

@dancmeyers do you mind taking a look?

bpalermo added a commit to bpalermo/rules_clojure that referenced this pull request Aug 22, 2026
This fork existed for two reasons: to make the rules load under Bazel 9, and to
publish the result to the Bazel Central Registry so that Clojure projects on
Bazel 9 had something to depend on. The first is done and offered upstream as
griffinbank#108. The second is no longer worth doing.

bpalermo/rules_clj now covers the same ground as an independent implementation
rather than a patched fork — compilation through a persistent worker, deps.edn
resolved into a lockfile, BUILD generation, ClojureScript, native images — and
maintaining two rulesets that do the same job would mean splitting attention
between them and asking users to choose.

Nothing is removed. The Bazel 9 commits stay here to be cherry-picked, and griffinbank#108
stays open in case upstream wants it. What changes is the expectation: no
releases, no registry entry, and a README that says so before someone adopts it.
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.

1 participant