Skip to content

Commit c820dd0

Browse files
Upgrade rules_cc 0.0.16 and rules_java 8.3.1
Both versions are again compatible with WORKSPACE mode on Bazel 8. The version also extends the compatibility down to Bazel 6. Add repo_name = "com_google_protobuf" to examples/MODULE.bazel. Bazel 6,7,and 8 (in WORKSPACE mode) still expect this is the name of the repo. (Default value of --proto_compiler flag). There's no way to change this without breaking compatibility with WORKSPACE mode. Remove local_repository(name = protobuf) from WORKSPACE. The repository is now consistently called com_google_protobuf in both WORKSPACE and Bzlmod mode. Rename uses of @protobuf to @com_google_protobuf. PiperOrigin-RevId: 695579489
1 parent c9a4aa9 commit c820dd0

File tree

8 files changed

+42
-48
lines changed

8 files changed

+42
-48
lines changed

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ module(
1515
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
1616
bazel_dep(name = "bazel_skylib", version = "1.7.0")
1717
bazel_dep(name = "jsoncpp", version = "1.9.6")
18-
bazel_dep(name = "rules_cc", version = "0.0.13")
18+
bazel_dep(name = "rules_cc", version = "0.0.16")
1919
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
20-
bazel_dep(name = "rules_java", version = "7.12.2")
20+
bazel_dep(name = "rules_java", version = "8.3.2")
2121
bazel_dep(name = "rules_jvm_external", version = "6.3")
2222
bazel_dep(name = "rules_kotlin", version = "1.9.6")
2323
bazel_dep(name = "rules_license", version = "1.0.0")

WORKSPACE

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ workspace(name = "com_google_protobuf")
55
# buildifier: disable=duplicated-name
66
local_repository(name = "com_google_protobuf", path = ".")
77

8-
# Second self-reference that makes it possible to load proto rules from @protobuf.
9-
# buildifier: disable=duplicated-name
10-
local_repository(name = "protobuf", path = ".")
11-
128
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
139

1410
local_repository(
@@ -95,6 +91,12 @@ load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependen
9591

9692
apple_support_dependencies()
9793

94+
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
95+
96+
rules_java_dependencies()
97+
98+
rules_java_toolchains()
99+
98100
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies")
99101

100102
rules_cc_dependencies()

benchmarks/BUILD.googleapis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131
load(
32-
"@protobuf//bazel:proto_library.bzl",
32+
"@com_google_protobuf//bazel:proto_library.bzl",
3333
"proto_library",
3434
)
3535

csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/BUILD.bazel

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# example.
66

77
load("@bazel_skylib//rules:build_test.bzl", "build_test")
8-
load("@protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
9-
load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library")
10-
load("@protobuf//bazel:proto_library.bzl", "proto_library")
11-
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
8+
load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
9+
load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
10+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
11+
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
1212
load("@rules_cc//cc:defs.bzl", "cc_binary")
1313
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
1414
load("@rules_python//python:py_binary.bzl", "py_binary")
@@ -25,7 +25,7 @@ load("@rules_python//python:py_binary.bzl", "py_binary")
2525
proto_library(
2626
name = "addressbook_proto",
2727
srcs = ["addressbook.proto"],
28-
deps = ["@protobuf//:timestamp_proto"],
28+
deps = ["@com_google_protobuf//:timestamp_proto"],
2929
)
3030

3131
# The cc_proto_library rule generates C++ code for a proto_library rule. It
@@ -45,8 +45,8 @@ cc_binary(
4545
srcs = ["add_person.cc"],
4646
deps = [
4747
":addressbook_cc_proto",
48-
"@protobuf",
49-
"@protobuf//src/google/protobuf/util:time_util",
48+
"@com_google_protobuf//:protobuf",
49+
"@com_google_protobuf//src/google/protobuf/util:time_util",
5050
],
5151
)
5252

@@ -55,8 +55,8 @@ cc_binary(
5555
srcs = ["list_people.cc"],
5656
deps = [
5757
":addressbook_cc_proto",
58-
"@protobuf",
59-
"@protobuf//src/google/protobuf/util:time_util",
58+
"@com_google_protobuf//:protobuf",
59+
"@com_google_protobuf//src/google/protobuf/util:time_util",
6060
],
6161
)
6262

examples/MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Bazel module dependencies"""
2-
bazel_dep(name = "protobuf", version = "0.0.0", dev_dependency = True)
32

3+
bazel_dep(name = "protobuf", version = "0.0.0", repo_name = "com_google_protobuf")
44
local_path_override(
55
module_name = "protobuf",
66
path = "..",
77
)
88

99
bazel_dep(name = "bazel_skylib", version = "1.0.3")
10-
bazel_dep(name = "rules_cc", version = "0.0.1")
11-
bazel_dep(name = "rules_java", version = "7.3.0")
10+
bazel_dep(name = "rules_cc", version = "0.0.16")
11+
bazel_dep(name = "rules_java", version = "8.3.2")
1212
bazel_dep(name = "rules_pkg", version = "0.7.0")
1313
bazel_dep(name = "rules_python", version = "0.25.0")

examples/WORKSPACE

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99
# before they get merged. You'll want to use the following instead:
1010
#
1111
# http_archive(
12-
# name = "protobuf",
12+
# name = "com_google_protobuf",
1313
# sha256 = "c29d8b4b79389463c546f98b15aa4391d4ed7ec459340c47bffe15db63eb9126",
1414
# strip_prefix = "protobuf-3.21.3",
1515
# urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz"],
@@ -20,11 +20,6 @@ local_repository(
2020
path = "..",
2121
)
2222

23-
local_repository(
24-
name = "protobuf",
25-
path = "..",
26-
)
27-
2823
# Similar to com_google_protobuf but for Java lite. If you are building
2924
# for Android, the lite version should be preferred because it has a much
3025
# smaller code size.
@@ -42,6 +37,20 @@ http_archive(
4237
url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
4338
)
4439

45-
load("@protobuf//:protobuf_deps.bzl", "protobuf_deps")
40+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
4641

4742
protobuf_deps()
43+
44+
http_archive(
45+
name = "rules_java",
46+
sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de",
47+
urls = [
48+
"https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz",
49+
],
50+
)
51+
52+
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
53+
54+
rules_java_dependencies()
55+
56+
rules_java_toolchains()

protobuf_deps.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ def protobuf_deps():
9090
if not native.existing_rule("rules_cc"):
9191
http_archive(
9292
name = "rules_cc",
93-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
94-
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
95-
strip_prefix = "rules_cc-0.0.13",
93+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
94+
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
95+
strip_prefix = "rules_cc-0.0.16",
9696
)
9797

9898
if not native.existing_rule("rules_java"):
9999
http_archive(
100100
name = "rules_java",
101-
url = "https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz",
102-
sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83",
101+
url = "https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz",
102+
sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de",
103103
)
104104

105105
if not native.existing_rule("rules_shell"):

0 commit comments

Comments
 (0)