Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract dev_deps_repositories() from WORKSPACE and remove //private #1656

Merged
merged 2 commits into from
Dec 8, 2024

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Nov 29, 2024

Description

dev_deps_repositories() encapsulates the instantiation of repositories used only for rules_scala development. Also removes the unused //private package and its WORKSPACE statements. Part of #1482 and #1652.

Replaces existing new_local_repository calls with complete nested repositories (with their own WORKSPACE files) and local_repository calls in the main WORKSPACE file. The first commit, however, calls native.{,new_}local_repository inside dev_deps_repositories(), in case we wish to use that implementation instead.

Motivation

Both WORKSPACE and Bzlmod builds can use this macro. However, the two commits in this pull request reflect different strategies towards handling the existing new_local_repository calls.

Either way, we need to update the new_local_repository calls because:

There are two paths we can go by (but in the long run, there's still time to change the road we're on):

  1. Replacing the new_local_repository instances with complete nested repositories is compatible with Bazel 6, 7, and 8, both under WORKSPACE and Bzlmod. (MODULE.bazel will use a combination of bazel_dep() and local_path_override().) That's the change reflected by the pull request as a whole.

  2. If keeping the new_local_repository calls is preferable, we'll have to use native.new_local_repository and native.local_repository in dev_deps_repositories(). Then, when we switch to building with Bazel 7 by default, we'll have to load local.bzl and strip the native. prefixes.

`dev_deps_repositories()` encapsulates the instantiation of repositories
used only for `rules_scala` development. Also removes the unused
`//private` package and its `WORKSPACE` statements. Part of bazelbuild#1482.

Both `WORKSPACE` and Bzlmod builds can use this macro, though how Bzlmod
will use it will depend on whether we continue building with Bazel 6.

`@bazel_tools//tools/build_defs/repo:local.bzl` isn't available under
Bazel 6. To continue building with Bazel 6 under Bzlmod, we will need to
call `dev_deps_repositories()` from `WORKSPACE.bzlmod` to continue using
`native.{,new_}local_repository()`.

If we switch to Bazel 7, we can load `local.bzl` and strip the `native.`
prefix from the `{,new_}local_repository()` calls. Then we can call
`dev_deps_repositories()` from a module extension instead of from
`WORKSPACE.bzlmod`.

Another alternative would be updating the local repositories to become
proper nested repositories. Then we can call `local_repository()` from
`WORKSPACE` and call `bazel_dep()` and `local_path_override()` from
`MODULE.bazel`. In that case, we'd remove the `{,new_}local_repository`
calls from `dev_deps_dependencies()`, and remove
`proto_cross_repo_boundary_repository()` entirely.
Removes `native.{,new_}local_repository()` calls in macros in favor of
`local_repository` calls from `WORKSPACE`. Part of bazelbuild#1482.

`native.{,new_}local_repository()` isn't available under Bzlmod,
`@bazel_tools//tools/build_defs/repo:local.bzl` with the Starlarkified
definitions isn't available under Bazel 6, and Bazel 8 compatibility
work is imminent. Redefining the repositories in this way will be
compatible with Bazel 6, 7, and 8, both under `WORKSPACE` and Bzlmod.
(`MODULE.bazel` will use a combination of `bazel_dep()` and
`local_path_override()`.)
Copy link
Collaborator

@simuons simuons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mbland!

Having dev dependencies in a single place is a nice thing.

And by the way

@liucijus liucijus merged commit 8d9e1f8 into bazelbuild:master Dec 8, 2024
2 checks passed
@mbland mbland deleted the bzlmod-dev-deps branch December 8, 2024 19:11
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.

3 participants