Issue
I want to share a problem that I need to solve, and I can't figure the best way to do it.
Currently, for our microservices projects (Spring) we have some in-house shared libraries that we develop. Those libraries are versioned with Bitbucket, and we have two ways to handle the deployment and usage:
Git Submodule: for this case, we embed the shared libraries inside the microservice project as a git submodule. The main issue for this approach is that, with more frequency than I would expect, developers mix the reference and commit the microservice pointing to a wrong branch of the submodule.
Regular dependency: we do the development of the shared library as a separate project, and then compile it with a pipeline and deploy to artifactory. Then we add the maven dependency as usual. The main CON for this approach is that the library versioning (maven versioning) is harder to manage and is more difficult to trace back the reference used for any microservice deploy.
So, I would love to hear your approached and recommendations for this case, what do you do in your projects?
Regards!
Solution
You can use Option 2, along with you can prefer the use of multimodule maven project
https://spring.io/guides/gs/multi-module/
You can keep it inside a framework repository assume it will be your parent repository and you can include it in your child projects, there way parent keeps on maintaining the version, like eg: how spring-boot-starter-parent works
https://www.springboottutorial.com/spring-boot-starter-parent
What does spring-boot-starter-parent exactly do in pom file?
Answered By - Madhankumar