I have two services A and B which placed in monorepo in different maven modules, also they have Aggregate pom.xml which contains the next modules:
<modules>
<module>A</module>
<module>B</module>
</modules>
Both services are talking through gRPC and have common protocol which described in the proto files.
The grpc-java manual says, that I must put my proto files into src/main/resourses/proto folder.
It means I have to copy the same proto files bewteen two services:
A/src/main/resourses/proto/somefile.protoB/src/main/resourses/proto/somefile.proto
Which is code duplication actually. The main question - How can I share and compile proto files between two maven modules in monorepo?
I have done the next:
- Created the separate library which contains only proto files. Let's call it C.
- Added C dependency to A and B modules.
Aggregated
pom.xmllooks like:
<modules>
<module>C</module>
<module>A</module>
<module>B</module>
</modules>
The approach seems quite havy for that case and I don't want to have a separate maven module for that. Moreover, I will definetley face with a problem, if I use different language for B service (something other than java and maven). Is there a known solution for this problem? Can I share protofiles without separate library/module? Any examples appreciated.