grpc-spring icon indicating copy to clipboard operation
grpc-spring copied to clipboard

proto文件如何管理

Open bli22ard opened this issue 3 years ago • 4 comments

按照文档建议,proto为一个单独的interface项目,其他项目引入这个interface项目时候,这个interface项目是生成好grpc所需的java class文件,然后提交到maven仓库,还是把interface作为 git的 submodule 引入呢,这两种方式哪种更合理一些

bli22ard avatar May 09 '22 02:05 bli22ard

English

‐---------------

IMO you should build the interface project once and upload it to a maven repository. That way you have control about versioning it, and for the other developers it is just a library like any other.

Does that answer your question?

ST-DDT avatar May 09 '22 05:05 ST-DDT

如果proto每次生成后提交到maven仓库, 那么开发过程中, 就需要先将proto 生成 jar , 上传到maven仓库,这样maven仓库就会有开发阶段的 proto 的jar,这样是不是不利于maven仓库的 jar 版本管理

bli22ard avatar May 10 '22 02:05 bli22ard

  • So first you only upload the proto file to maven,
  • then you download it from there
  • and build the proto/grpc jar
  • and upload that to maven
  • and use those for development?

Why do you separate the proto files from the jar upload? Different distributors/team?

If you only need the jar for one project, then you can just build it as part of your project. If you need it multiple times, then you should add a build pipeline that builds and uploads it for you.

Storing it in maven saves you build time and config while it may have a dependency on specific protobuf and grpc version ranges due to internal API usage in the generated code. I never really had much issues with that though.

ST-DDT avatar May 10 '22 06:05 ST-DDT

好的, 谢谢, 文档最佳实战, 可以补充这个方案进去

bli22ard avatar May 13 '22 02:05 bli22ard