From 1dd29ef9deb042a7afa66428ad43b376563e4208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szynkiewicz?= Date: Mon, 26 Jul 2021 13:44:24 +0200 Subject: [PATCH] Bump gRPC version, overriding protoc-os-classifier, optional fields in proto fixes #16451 --- bom/application/pom.xml | 6 ++--- .../main/asciidoc/grpc-getting-started.adoc | 5 ++++- .../quarkus/grpc/deployment/GrpcCodeGen.java | 6 ++--- .../protoc/plugin/MutinyGrpcGenerator.java | 6 +++++ extensions/grpc/stubs/pom.xml | 22 +++++++++++++++++++ 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index a2801854fbb97..df7a3873ae230 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -189,9 +189,9 @@ 1.38.0 2.1 - 1.35.0 - 1.0.1 - 3.14.0 + 1.38.1 + 1.2.0 + 3.17.3 ${protobuf-java.version} 4.6.1 1.0.1 diff --git a/docs/src/main/asciidoc/grpc-getting-started.adoc b/docs/src/main/asciidoc/grpc-getting-started.adoc index beea2eda9401a..25405017bf0c5 100644 --- a/docs/src/main/asciidoc/grpc-getting-started.adoc +++ b/docs/src/main/asciidoc/grpc-getting-started.adoc @@ -65,9 +65,12 @@ With this configuration, you can put your service and message definitions in the `quarkus-maven-plugin` will generate Java files from your `proto` files. `quarkus-maven-plugin` retrieves a version of `protoc` (the protobuf compiler) from Maven repositories. The retrieved version matches your operating system and CPU architecture. -If this retrieved version does not work in your context, you can download the suitable binary and specify the location via +If this retrieved version does not work in your context, you can either force to use a different OS classifier with +`-Dquarkus.grpc.protoc-os-classifier=your-os-classifier` (e.g. `osx-x86_64`). +You can also download the suitable binary and specify the location via `-Dquarkus.grpc.protoc-path=/path/to/protoc`. + Alternatively to using the `generate-code` goal of the `quarkus-maven-plugin`, you can use `protobuf-maven-plugin` to generate these files, more in <> Let's start with a simple _Hello_ service. diff --git a/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcCodeGen.java b/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcCodeGen.java index 3e83504fe61fa..91439bc10b1b0 100644 --- a/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcCodeGen.java +++ b/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/deployment/GrpcCodeGen.java @@ -113,7 +113,7 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { int resultCode = process.waitFor(); if (resultCode != 0) { throw new CodeGenException("Failed to generate Java classes from proto files: " + protoFiles + - " to " + outDir.toAbsolutePath().toString()); + " to " + outDir.toAbsolutePath()); } return true; } @@ -199,7 +199,7 @@ private void initExecutables(Path workDir, AppModel model) throws CodeGenExcepti if (executables == null) { Path protocPath; String protocPathProperty = System.getProperty("quarkus.grpc.protoc-path"); - String classifier = osClassifier(); + String classifier = System.getProperty("quarkus.grpc.protoc-os-classifier", osClassifier()); if (protocPathProperty == null) { protocPath = findArtifactPath(model, PROTOC_GROUPID, PROTOC, classifier, EXE); } else { @@ -310,7 +310,7 @@ private static Path writeScript(Path buildDir, Path pluginPath, String shebang, private static void writePluginExeCmd(Path pluginPath, BufferedWriter writer) throws IOException { writer.write("\"" + JavaBinFinder.findBin() + "\" -cp \"" + - pluginPath.toAbsolutePath().toString() + "\" " + quarkusProtocPluginMain); + pluginPath.toAbsolutePath() + "\" " + quarkusProtocPluginMain); writer.newLine(); } diff --git a/extensions/grpc/protoc/src/main/java/io/quarkus/grpc/protoc/plugin/MutinyGrpcGenerator.java b/extensions/grpc/protoc/src/main/java/io/quarkus/grpc/protoc/plugin/MutinyGrpcGenerator.java index d4cdbdbc40d53..348b88c57c01d 100644 --- a/extensions/grpc/protoc/src/main/java/io/quarkus/grpc/protoc/plugin/MutinyGrpcGenerator.java +++ b/extensions/grpc/protoc/src/main/java/io/quarkus/grpc/protoc/plugin/MutinyGrpcGenerator.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -35,6 +36,11 @@ private String getMethodJavaDocPrefix() { return " "; } + @Override + protected List supportedFeatures() { + return Collections.singletonList(PluginProtos.CodeGeneratorResponse.Feature.FEATURE_PROTO3_OPTIONAL); + } + @Override public List generateFiles(PluginProtos.CodeGeneratorRequest request) throws GeneratorException { diff --git a/extensions/grpc/stubs/pom.xml b/extensions/grpc/stubs/pom.xml index 6e3ef43a0e3f7..5c41b5399a993 100644 --- a/extensions/grpc/stubs/pom.xml +++ b/extensions/grpc/stubs/pom.xml @@ -21,6 +21,28 @@ io.quarkus quarkus-mutiny + + io.grpc + grpc-protobuf + + + org.codehaus.mojo + animal-sniffer-annotations + + + org.checkerframework + checker-qual + + + com.google.guava + guava + + + com.google.errorprone + error_prone_annotations + + + io.grpc grpc-stub