Skip to content

Commit 6de5110

Browse files
authored
feat: dynamically determine protobuf version in build.gradle (#1753)
* feat: dynamically determine protobuf version in build.gradle * add code comment * add a method to sync versions from googleapis * add a seperate dict for synced version * restore protobuf version in dependencies.properties * add synced version after reading properties * combine two properties * remove protobuf version in dependencies.properties * empty commit * Revert "remove protobuf version in dependencies.properties" This reverts commit 22d3d0c. * add comment for protobuf version * make a copy of properties * change comment * change comments
1 parent 97cd3b7 commit 6de5110

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

gax-java/dependencies.properties

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ version.gax_httpjson=0.114.1-SNAPSHOT
2323
# Versions for dependencies which actual artifacts differ between Bazel and Gradle.
2424
# Gradle build depends on prebuilt maven artifacts, while Bazel build depends on Bazel workspaces
2525
# with the sources.
26+
# The protobuf version is only used for generating gradle files for showcase module,
27+
# not for self-service clients (from googleapis project).
2628
version.com_google_protobuf=3.23.2
2729
version.google_java_format=1.15.0
2830
version.io_grpc=1.54.0

rules_java_gapic/java_gapic_pkg.bzl

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
# limitations under the License.
1414

1515
load("@com_google_api_gax_java_properties//:dependencies.properties.bzl", "PROPERTIES")
16+
load("@com_google_protobuf//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
1617

1718
def _wrapPropertyNamesInBraces(properties):
1819
wrappedProperties = {}
1920
for k, v in properties.items():
2021
wrappedProperties["{{%s}}" % k] = v
2122
return wrappedProperties
2223

23-
_PROPERTIES = _wrapPropertyNamesInBraces(PROPERTIES)
24+
# Before this replacement, there was a problem (e.g., b/284292352) when
25+
# the version of protobuf defined in googleapis is higher than protobuf
26+
# defined in gax-java/dependencies.properties, use this replacement to
27+
# sync the two versions.
28+
SYNCED_PROPERTIES = PROPERTIES | {"version.com_google_protobuf": PROTOBUF_JAVA_VERSION}
29+
_PROPERTIES = _wrapPropertyNamesInBraces(SYNCED_PROPERTIES)
2430

2531
# ========================================================================
2632
# General packaging helpers.
@@ -63,7 +69,7 @@ def _gapic_pkg_tar_impl(ctx):
6369
for f in dep.files.to_list():
6470
deps.append(f)
6571

66-
samples =[]
72+
samples = []
6773
for s in ctx.attr.samples:
6874
for f in s.files.to_list():
6975
samples.append(f)

0 commit comments

Comments
 (0)