Skip to content

Commit

Permalink
fix: Reflect protobuf updates into MODULE.bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
Borja Lorente committed Jul 12, 2023
1 parent 9911fc9 commit 6f95ae8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
14 changes: 12 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ module(
repo_name = "contrib_rules_jvm",
)

# TODO: This should be read from repositories.bzl, but we can't until this issue is solved:
# - https://github.com/bazelbuild/bazel/issues/17880
PROTOBUF_VERSION = "21.7"
# The java packages are published to maven under a different versioning scheme.
PROTOBUF_JAVA_VERSION = "3.{}".format(PROTOBUF_VERSION)

bazel_dep(name = "apple_rules_lint", version = "0.3.2")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.2")
bazel_dep(name = "gazelle", version = "0.31.1", repo_name = "bazel_gazelle")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = PROTOBUF_VERSION, repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.0.6")
bazel_dep(name = "rules_go", version = "0.40.1", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_java", version = "6.1.1")
bazel_dep(name = "rules_jvm_external", version = "5.3")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_proto", version = "5.3.0-{}".format(PROTOBUF_VERSION))
bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc")

non_module_deps = use_extension("//java/private:non-module-deps.bzl", "non_module_deps")
Expand Down Expand Up @@ -119,6 +125,10 @@ maven.install(
# Spotbugs deps
"org.slf4j:slf4j-api:1.7.32",
"org.slf4j:slf4j-jdk14:1.7.32",

# We explicitly declare a protobuf runtime version
# so that it coincides with the one we use to generate the code.
"com.google.protobuf:protobuf-java:{}".format(PROTOBUF_JAVA_VERSION),
] + IO_GRPC_GRPC_JAVA_ARTIFACTS,
fail_if_repin_required = True,
generate_compat_repositories = True,
Expand Down
9 changes: 2 additions & 7 deletions java/private/non-module-deps.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//:repositories.bzl", "io_grpc_grpc_java")

def _non_module_dependencies_impl(mctx):
maybe(
http_archive,
name = "io_grpc_grpc_java",
sha256 = "b6cfc524647cc680e66989ab22a10b66dc5de8c6d8499f91a7e633634c594c61",
strip_prefix = "grpc-java-1.51.1",
urls = ["https://github.com/grpc/grpc-java/archive/v1.51.1.tar.gz"],
)
io_grpc_grpc_java()

non_module_deps = module_extension(
implementation = _non_module_dependencies_impl,
Expand Down
20 changes: 12 additions & 8 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def contrib_rules_jvm_deps():
)

def contrib_rules_jvm_gazelle_deps():

io_grpc_grpc_java()

maybe(
http_archive,
name = "bazel_gazelle",
Expand All @@ -79,14 +82,6 @@ def contrib_rules_jvm_gazelle_deps():
url = "https://github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
)

maybe(
http_archive,
name = "io_grpc_grpc_java",
sha256 = "17dd91014032a147c978ae99582fddd950f5444388eae700cf51eda0326ad2f9",
strip_prefix = "grpc-java-1.56.1",
urls = ["https://github.com/grpc/grpc-java/archive/v1.56.1.tar.gz"],
)

maybe(
http_archive,
name = "rules_proto",
Expand All @@ -96,3 +91,12 @@ def contrib_rules_jvm_gazelle_deps():
strip_prefix = "rules_proto-5.3.0-{}".format(PROTOBUF_VERSION),
url = "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-{}.tar.gz".format(PROTOBUF_VERSION),
)

def io_grpc_grpc_java():
maybe(
http_archive,
name = "io_grpc_grpc_java",
sha256 = "17dd91014032a147c978ae99582fddd950f5444388eae700cf51eda0326ad2f9",
strip_prefix = "grpc-java-1.56.1",
urls = ["https://github.com/grpc/grpc-java/archive/v1.56.1.tar.gz"],
)
2 changes: 2 additions & 0 deletions third_party/protobuf_version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Please keep in sync with MODULE.bazel until
# https://github.com/bazelbuild/bazel/issues/17880 is solved.
PROTOBUF_VERSION = "21.7"

# The java packages are published to maven under a different versioning scheme.
Expand Down

0 comments on commit 6f95ae8

Please sign in to comment.