grpc / grpc-java

The Java gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/java/
Apache License 2.0
11.34k stars 3.81k forks source link

manjaro linux Unknown option: --proto_path #11357

Closed zhaopei0418 closed 1 month ago

zhaopei0418 commented 1 month ago

manjaro linux

    <protocArtifact>com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</protocArtifact>
    <pluginId>grpc-java</pluginId>
    <protocArtifact>io.grpc:protoc-gen-grpc-java:1.64.0:exe:${os.detected.classifier}</protocArtifact>
    <!--默认值,proto源文件路径-->
    <protoSourceRoot>${project.basedir}/src/main/proto</protoSourceRoot>
    <!--默认值,proto目标java文件路径-->
    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
    <!--设置是否在生成java文件之前清空outputDirectory的文件,默认值为true,设置为false时也会覆盖同名文件-->
    <clearOutputDirectory>false</clearOutputDirectory>

exec: mvn clean protobuf:compile

result:

[ERROR] PROTOC FAILED: /run/media/zhaopei/data2/projects/manjaro/signservice/target/protoc-plugins/protoc-gen-grpc-java-1.64.0-linux-x86_64.exe: Unknown option: --proto_path=/run/media/zhaopei/data2/projects/manjaro/signservice/src/main/proto

[ERROR] /run/media/zhaopei/data2/projects/manjaro/signservice/src/main/proto/sign.proto [0:0]: /run/media/zhaopei/data2/projects/manjaro/signservice/target/protoc-plugins/protoc-gen-grpc-java-1.64.0-linux-x86_64.exe: Unknown option: --proto_path=/run/media/zhaopei/data2/projects/manjaro/signservice/src/main/proto
kannanjgithub commented 1 month ago

Can you try without the protoSourceRoot option since the value for it you specified is the default anyway?

ejona86 commented 1 month ago

<protocArtifact>io.grpc:protoc-gen-grpc-java:1.64.0:exe:${os.detected.classifier}</protocArtifact>

That should not be a protocArtifact. It is overwriting the previous setting:

<protocArtifact>com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</protocArtifact>

Instead, you want to use protoc-gen-grpc-java as the pluginArtifact. See the example pom.xml: https://github.com/grpc/grpc-java/blob/b181e495ab0ffdc0cfa70679aaa8f7fe6b7a4985/examples/pom.xml#L102-L104

ejona86 commented 1 month ago

Seems like this is resolved. If not, comment, and it can be reopened.