Context:
We have Java maven Multi Microservices Project. The structure for each microservice is a contracts package and a service package.
When we update a version of a specific microservice the versions-maven-plugin knows to replace the version in all the dependents poms. Once there is a change in one file of a service, the build system knows to run this service.
The Problem:
We have some contracts packages that depend on other contracts package that dependence on other contracts packages (and so on). So we have transitive dependencies and it doesn't work well with the versioning mechanism.
Example:
A contracts use B contracts B contracts use C contracts => A contracts use C contracts transitively = without defining it explicitly in the POM. => When C contracts change the build system runs only B and C microservices.
Questions:
- Does it make sense that one service's contracts includes another service's contracts?
There are cases where we have a class that is used across multiservices and then we put it in a common library.
There are cases where the class is shared between only 3 microservices so I am not sure it should be in common. Duplication per microservice sound like a bad design because the structure needs to be identical in all places.
- How to solve it the transitive dependencies issue technically without the programmer's awareness to define the dependency explicitly in the pom?