Handling multiple interconnected maven projects with differing versions

Answered

Say you have three repos, each with a maven project: domain, server, gui

Server depends on domain and gui depends on server and domain.

The poms for each project define the current version as 0-SNAPSHOT. But there are some releases like 0.1.0.

So say all projects are currently defined as 0-SNAPSHOT in the source but domain was released as 0.1.0, server as 0.2.0 and gui as 0.3.0 and these dependencies are in the current POMs: gui -> server:0.2.0, server -> domain:0.1.0

When you open these projects in one IntelliJ project IntelliJ does not understand that they're connected, e.g. it references the maven releases 0.1.0 and 0.2.0 of domain and server, respectively. If I do some refactoring in domain then none of the changes are reflected in the dependent projects. For that I have to change the dependencies to 0-SNAPSHOT in both gui and server or I change the version of domain to 0.1.0.

Either way I have to manually update the poms to properly work with this multi-project structure. When you actually have more than a dozen microservices it's really hard to work with if you want to make one change in a base module like domain which is then reflected in all dependent modules. Or if you just want to find the code references in the source code instead of the JARs.

So, is there some way of handling this in a better way? I understand this could get confusing for IntelliJ and the user if it would always just disregard the version of the dependency and just use the one in the project but I feel this could be improved in some way.

I did a lot of googling for this but it's really hard to properly describe the problem here, even less so in a short google query.

0
1 comment

Hello, Simon!

For a setup you have described IDEA (and Maven) are treating those Projects as independent.

Usually, when working with multiple interconnected Projects (Modules) it's worth looking into Maven's Project Inheritance and/or Project Aggregation. This way you will be able to tell both IDEA and Maven that those Modules rely on one another and this will, hopefully, make dealing with the Project as a whole much easier for you.

 

Let me know if that would work for you!

0

Please sign in to leave a comment.