Migrating to Bazel Modules (a.k.a. Bzlmod) - Maintaining Compatibility, Part 1
As we're well aware by now, Bzlmod is the new hotness, and WORKSPACE is old and
busted and going away in Bazel 9. However, Bazel 8 still supports
WORKSPACE
, and thus legacy WORKSPACE
usage won't completely disappear for
some years yet. Despite the Bazel community's efforts to help facilitate Bzlmod
migrations (including this blog series), some projects may remain unable to
migrate sooner than later.
What's more, publishing your repository for use by other projects raises the
challenge of supporting a range of older and newer versions of its dependencies.
Your repository should work with the newest versions of Bazel, rules_java
,
protobuf
, and other dependencies in order to stay current. However, not every
project that could benefit from the latest version of your repository will want
to upgrade these other dependencies right away.
This post describes how to design a repository to remain compatible with both
WORKSPACE
and Bzlmod, and with newer and older dependency versions. Just as
importantly, in the next two posts, we'll discuss testing approaches to help
ensure that this remains the case.