0
votes

I have a set of Spring Boot-based microservice projects. Each is a multi-module project, with a root POM, and module directories with their own POMs. Each root POM has, as it's parent, the spring-boot-starter-parent artifact.

Each of these multi-module projects currently build successfully, and result in 3 artifacts each. However, each project has it's own version.

I want to accomplish 2 things:

  1. Stamp this set of microservice projects with a common version across all of them.
  2. Enforce a common set of dependency versions across all of them, similar to how <dependencyManagement> works within a project. (e.g. force each service to use version x.y.z of the example-common-dependency dependency)

Is this possible in Maven?

If not, what about Gradle?

Thank you for your help!

1
If you want the same version for all your microservices, couldn't you just build them in one multi-module project? - J Fabian Meier
Yes, I thought about doing that. However, these services were developed independently, and have independent build/deploy processes already in place. Re-arranging them all into a single multi-module project seemed like more effort than I wanted to take on. - Jack Straw

1 Answers

0
votes

Yes, there are several ways you can accomplish both #1 and #2 using maven. Check out the maven docs on POMs: https://maven.apache.org/guides/introduction/introduction-to-the-pom.html. There are pros and cons to each type of setup. The "Project Inheritance" could do much, if not all, of #1 and #2 for you. That might be a simple way to start. You may also want to look at using spring boot without the spring boot parent: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-maven-without-a-parent. This could give you more flexibility b/c a maven project cannot have multiple parents. Hope this helps.