Skip to content

Commit

Permalink
Merge pull request #18992 from michalszynkiewicz/bump-grpc-and-custom…
Browse files Browse the repository at this point in the history
…-os-classifier

Bump gRPC version and a way to override protoc-os-classifier
  • Loading branch information
michalszynkiewicz authored Jul 27, 2021
2 parents 76d1dc7 + 1dd29ef commit 964f4d9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
6 changes: 3 additions & 3 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@
<google-http-client.version>1.38.0</google-http-client.version>
<scram-client.version>2.1</scram-client.version>
<!-- Make sure to check compatibility between these 2 gRPC components before upgrade -->
<grpc.version>1.35.0</grpc.version> <!-- when updating, verify if com.google.auth should not be updated too -->
<grpc-jprotoc.version>1.0.1</grpc-jprotoc.version>
<protobuf-java.version>3.14.0</protobuf-java.version>
<grpc.version>1.38.1</grpc.version> <!-- when updating, verify if com.google.auth should not be updated too -->
<grpc-jprotoc.version>1.2.0</grpc-jprotoc.version>
<protobuf-java.version>3.17.3</protobuf-java.version>
<protoc.version>${protobuf-java.version}</protoc.version>
<picocli.version>4.6.1</picocli.version>
<google-cloud-functions.version>1.0.1</google-cloud-functions.version>
Expand Down
5 changes: 4 additions & 1 deletion docs/src/main/asciidoc/grpc-getting-started.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<Generating Java files from proto with protobuf-maven-plugin>>

Let's start with a simple _Hello_ service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +36,11 @@ private String getMethodJavaDocPrefix() {
return " ";
}

@Override
protected List<PluginProtos.CodeGeneratorResponse.Feature> supportedFeatures() {
return Collections.singletonList(PluginProtos.CodeGeneratorResponse.Feature.FEATURE_PROTO3_OPTIONAL);
}

@Override
public List<PluginProtos.CodeGeneratorResponse.File> generateFiles(PluginProtos.CodeGeneratorRequest request)
throws GeneratorException {
Expand Down
22 changes: 22 additions & 0 deletions extensions/grpc/stubs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
Expand Down

0 comments on commit 964f4d9

Please sign in to comment.