Skip to content

Commit 9a3c89c

Browse files
committed
bazel: make bzlmod bazel 6 compatible again
use_repo is not available in bazel 6 so we need to create our own extension that will call http_jar in bzlmod
1 parent 71d039f commit 9a3c89c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

bazeldnf/extensions.bzl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ based on: https://github.com/bazel-contrib/rules-template/blob/0dadcb716f06f6728
66
"""
77

88
load("@bazel_features//:features.bzl", "bazel_features")
9+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
910
load("//internal:rpm.bzl", rpm_repository = "rpm")
1011
load(":repositories.bzl", "bazeldnf_register_toolchains")
1112

@@ -226,3 +227,27 @@ bazeldnf = module_extension(
226227
"config": _config_tag,
227228
},
228229
)
230+
231+
def _protobuf_java_extension(module_ctx):
232+
http_jar(
233+
name = "protobuf-java",
234+
integrity = "sha256-0C+GOpCj/8d9Xu7AMcGOV58wx8uY8/OoFP6LiMQ9O8g=",
235+
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.3/protobuf-java-4.27.3.jar"],
236+
)
237+
238+
kwargs = {}
239+
if bazel_features.external_deps.extension_metadata_has_reproducible:
240+
kwargs["reproducible"] = True
241+
242+
if module_ctx.root_module_has_non_dev_dependency:
243+
kwargs["root_module_direct_deps"] = []
244+
kwargs["root_module_direct_dev_deps"] = ["protobuf-java"]
245+
else:
246+
kwargs["root_module_direct_deps"] = []
247+
kwargs["root_module_direct_dev_deps"] = ["protobuf-java"]
248+
249+
return module_ctx.extension_metadata(**kwargs)
250+
251+
protobuf_java = module_extension(
252+
implementation = _protobuf_java_extension,
253+
)

0 commit comments

Comments
 (0)