From bf217bfb8a28adc15cb9d9b74fbd8339b4825df3 Mon Sep 17 00:00:00 2001 From: shaod2 Date: Thu, 6 Feb 2025 17:17:38 -0500 Subject: [PATCH 1/4] Populate the pb::java feature extension to the protoc plugins that requires Protobuf Java feature resolution --- compiler/src/java_plugin/cpp/java_plugin.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/src/java_plugin/cpp/java_plugin.cpp b/compiler/src/java_plugin/cpp/java_plugin.cpp index c3aec58ed8e..f07505b721e 100644 --- a/compiler/src/java_plugin/cpp/java_plugin.cpp +++ b/compiler/src/java_plugin/cpp/java_plugin.cpp @@ -23,6 +23,7 @@ #include "java_generator.h" #include +#include #include #include #include @@ -57,6 +58,10 @@ class JavaGrpcGenerator : public protobuf::compiler::CodeGenerator { protobuf::Edition GetMaximumEdition() const override { return protobuf::Edition::EDITION_2023; } + std::vector GetFeatureExtensions() + const override { + return {GetExtensionReflection(pb::java)}; + } #else uint64_t GetSupportedFeatures() const override { return Feature::FEATURE_PROTO3_OPTIONAL; From b00a94dbc0d6a8752961ce4bf665c1b4036f375b Mon Sep 17 00:00:00 2001 From: shaod2 Date: Thu, 6 Feb 2025 17:32:42 -0500 Subject: [PATCH 2/4] fix build --- compiler/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/BUILD.bazel b/compiler/BUILD.bazel index 753f485074e..9186b8f04d3 100644 --- a/compiler/BUILD.bazel +++ b/compiler/BUILD.bazel @@ -13,6 +13,7 @@ cc_binary( visibility = ["//visibility:public"], deps = [ "@com_google_protobuf//:protoc_lib", + "@com_google_protobuf//:protoc_java", ], ) From 081a31ce2553db94b4d576eb3ea3d874d697c682 Mon Sep 17 00:00:00 2001 From: shaod2 Date: Thu, 6 Feb 2025 17:36:16 -0500 Subject: [PATCH 3/4] Adjust Protobuf version support --- compiler/src/java_plugin/cpp/java_plugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/src/java_plugin/cpp/java_plugin.cpp b/compiler/src/java_plugin/cpp/java_plugin.cpp index f07505b721e..6b7cc03d486 100644 --- a/compiler/src/java_plugin/cpp/java_plugin.cpp +++ b/compiler/src/java_plugin/cpp/java_plugin.cpp @@ -23,7 +23,9 @@ #include "java_generator.h" #include +#if GOOGLE_PROTOBUF_VERSION >= 5027000 #include +#endif #include #include #include From bd5eb6fb413c36d8aa069f430275e120d47aa0a1 Mon Sep 17 00:00:00 2001 From: shaod2 Date: Thu, 6 Feb 2025 17:39:59 -0500 Subject: [PATCH 4/4] Fix build --- compiler/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/BUILD.bazel b/compiler/BUILD.bazel index 9186b8f04d3..753f485074e 100644 --- a/compiler/BUILD.bazel +++ b/compiler/BUILD.bazel @@ -13,7 +13,6 @@ cc_binary( visibility = ["//visibility:public"], deps = [ "@com_google_protobuf//:protoc_lib", - "@com_google_protobuf//:protoc_java", ], )