Skip to content

Commit

Permalink
feat: dynamically determine protobuf version in build.gradle (#1753)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JoeWang1127 committed Jun 8, 2023
1 parent 97cd3b7 commit 6de5110
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gax-java/dependencies.properties
Expand Up @@ -23,6 +23,8 @@ version.gax_httpjson=0.114.1-SNAPSHOT
# Versions for dependencies which actual artifacts differ between Bazel and Gradle.
# Gradle build depends on prebuilt maven artifacts, while Bazel build depends on Bazel workspaces
# with the sources.
# The protobuf version is only used for generating gradle files for showcase module,
# not for self-service clients (from googleapis project).
version.com_google_protobuf=3.23.2
version.google_java_format=1.15.0
version.io_grpc=1.54.0
Expand Down
10 changes: 8 additions & 2 deletions rules_java_gapic/java_gapic_pkg.bzl
Expand Up @@ -13,14 +13,20 @@
# limitations under the License.

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

def _wrapPropertyNamesInBraces(properties):
wrappedProperties = {}
for k, v in properties.items():
wrappedProperties["{{%s}}" % k] = v
return wrappedProperties

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

# ========================================================================
# General packaging helpers.
Expand Down Expand Up @@ -63,7 +69,7 @@ def _gapic_pkg_tar_impl(ctx):
for f in dep.files.to_list():
deps.append(f)

samples =[]
samples = []
for s in ctx.attr.samples:
for f in s.files.to_list():
samples.append(f)
Expand Down

0 comments on commit 6de5110

Please sign in to comment.