akka-grpc
akka-grpc copied to clipboard
Failure to import Google annotations proto
Versions used
Akka version: 1.1.1
Expected Behavior
When creating the Java files from protobuf in Maven with
<plugin>
<groupId>com.lightbend.akka.grpc</groupId>
<artifactId>akka-grpc-maven-plugin</artifactId>
<version>${akka.grpc.version}</version>
<configuration>
<language>Java</language>
<includeStdTypes>true</includeStdTypes>
<protoPaths>
<protoPath>my_protos_path</protoPath>
</protoPaths>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
I'd expect the compiler to be able to pick up the standard file google/api/annotations.proto
and correctly compile the protobufs.
Actual Behavior
The compilation fails with
[ERROR] Failed to execute goal com.lightbend.akka.grpc:akka-grpc-maven-plugin:1.1.1:generate (default) on project registry: Execution default of goal com.lightbend.akka.grpc:akka-grpc-maven-plugin:1.1.1:generate failed: protoc exit code 1: google/api/annotations.proto: File not found.
For comparison, using
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.8.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier}</pluginArtifact>
<protoSourceRoot>my_protos_path</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
correctly creates the Java implementations.
I have also tried configuring <protocVersion>-v3.8.0</protocVersion>
to match the versions but it gives the same error.
Relevant logs
Relevant build logs shared above.
Reproducible Test Case
I'm currently unsure what's the best way to provide the reproducibility instructions. This example could be used as a base proto.
Indeed we don't currently include those by default. The includeStdTypes
flag introduced in #1136 will include google.protobuf
types, but not google.api
ones.
A quick solution would be to get the relevant proto files from https://github.com/googleapis/googleapis and include them in your project.
A second option is loading these .proto's from an artifact. This is not directly supported right now - the discussion under #152 contains a way to achieve this, though it is still rather verbose.
A third option is loading akka-grpc as a plugin to protobuf-maven-plugin instead of using the dedicated plugin. This can be done with something like:
<protocArtifact>com.google.protobuf:protoc:3.8.0:exe:${os.detected.classifier}</protocArtifact>
<protocPlugins>
<protocPlugin>
<id>akka-grpc</id>
<groupId>com.lightbend.akka.grpc</groupId>
<artifactId>akka-grpc-scalapb-protoc-plugin_2.12</artifactId>
<version>${akka.grpc.version}</version>
<mainClass>akka.grpc.gen.Main</mainClass>
</protocPlugin>
</protocPlugins>
This is not really properly documented right now yet, unfortunately.
Nice, thanks! I don't know if I should close or leave it open for tracking. Feel free to close if better for the team.
I don't know if I should close or leave it open for tracking. Feel free to close if better for the team.
I guess the first option is covered by the docs and the second option is covered by #152, so nothing further to do there.
I'm OK with leaving this issue open until we either have the third option documented, or have created an issue dedicated to documenting it.