Skip to content

Commit

Permalink
Add test local_repository calls to WORKSPACE
Browse files Browse the repository at this point in the history
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()`.)
  • Loading branch information
mbland committed Dec 2, 2024
1 parent eb03cee commit bd7eb76
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 54 deletions.
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# needed for the cross repo proto test
local_repository(
name = "proto_cross_repo_boundary",
path = "test/proto_cross_repo_boundary/repo",
)

local_repository(
name = "test_new_local_repo",
path = "third_party/test/new_local_repo",
)

local_repository(
name = "example_external_workspace",
path = "third_party/test/example_external_workspace",
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
Expand Down
40 changes: 0 additions & 40 deletions scala/private/extensions/dev_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@

load("//scala:scala_cross_version.bzl", "default_maven_server_urls")
load("//scala:scala_maven_import_external.bzl", "java_import_external")
load(
"//test/proto_cross_repo_boundary:repo.bzl",
"proto_cross_repo_boundary_repository",
)
load("//test/toolchains:jdk.bzl", "remote_jdk21_repositories")
load("//third_party/repositories:repositories.bzl", "repositories")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Once we switch to Bazel 7, uncomment this `load` statement remove the
# `native.` prefix from `local_repository` and `new_local_repository`.
# Update //test/proto_cross_repo_boundary:repo.bzl in the same way.
#load(
# "@bazel_tools//tools/build_defs/repo:local.bzl",
# "local_repository",
# "new_local_repository",
#)
load("@rules_java//java:repositories.bzl", "remote_jdk8_repos")

_BUILD_TOOLS_RELEASE = "5.1.0"
Expand All @@ -28,13 +15,6 @@ def dev_deps_repositories(
fetch_sources = False):
"""Instantiates internal only repos for development and testing
Once we're using Bazel 7, uncomment the `load()` statement for `local.bzl`
in this file and remove `native.` from the `native.{,new_}local_repository`
calls.
Until then, `dev_deps_repositories()` must be called from `WORKSPACE` or
`WORKSPACE.bzlmod`, as module extensions won't be able to use it.
Args:
name: unused macro parameter to satisfy Buildifier lint rules
maven_servers: servers to use when resolving Maven artifacts
Expand All @@ -50,26 +30,6 @@ def dev_deps_repositories(
),
)

# needed for the cross repo proto test
proto_cross_repo_boundary_repository()

native.local_repository(
name = "example_external_workspace",
path = "third_party/test/example_external_workspace",
)

native.new_local_repository(
name = "test_new_local_repo",
build_file_content = """
filegroup(
name = "data",
srcs = glob(["**/*.txt"]),
visibility = ["//visibility:public"],
)
""",
path = "third_party/test/new_local_repo",
)

# bazel's java_import_external has been altered in rules_scala to be a macro
# based on jvm_import_external in order to allow for other jvm-language
# imports (e.g. scala_import) the 3rd-party dependency below is using the
Expand Down
14 changes: 0 additions & 14 deletions test/proto_cross_repo_boundary/repo.bzl

This file was deleted.

1 change: 1 addition & 0 deletions test/proto_cross_repo_boundary/repo/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
File renamed without changes.
Empty file.
1 change: 1 addition & 0 deletions third_party/test/new_local_repo/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
5 changes: 5 additions & 0 deletions third_party/test/new_local_repo/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "data",
srcs = glob(["**/*.txt"]),
visibility = ["//visibility:public"],
)
Empty file.

0 comments on commit bd7eb76

Please sign in to comment.