javamavenintellij-ideawarmaven-multi-module

Develop war project referencing dependencies with repository per jar in Intellij


There is a big maven project with dozens of jars and a single war. Each jar represents a big function where a dedicated team works on. Let's say, 'inventory' jar includes necessary functionality to support that feature in our product and there is a dedicated team 'inventory' team is working on it.

As there are around 50 such functions/teams/jars - we want to try to isolate them from each other further and keep each jar in its own git repository. But then how to

Is there any suggestion how to isolate teams and simulate 'repository per jar' (like microservices) with maven and develop the project efficiently with Intellij with a support of Hotswap, navigation and etc? If it's even possible. Probably the question also brings up an understanding how to efficiently develop libraries.

The default behavior I suppose, it's to have a single repo with root aggregator maven project which includes all necessary 'submodules' and the single war module references to necessary jars through dependencies. Then everything works well. And Intellij perfectly supports hot swap, debug and etc. But is it possible to go away from monorepository and switch to multirepository per jar?

But if we want to have a single repo with only 'umbrella' maven war project which references to all jars as dependencies and develop each jar in its own git repo - then there is no easy way to develop it in Intellij with support of HotSwap, debug and reload resources and etc (or I don't know that way). We always have to rebuild dependency jar to install to local mvn repository to let it be taken up by war project. I tried importing Intellij modules but after the deployment of war in Intellij tomcat, the debug points to libraries (read-only) and not to my imported modules - the same as typical maven and tomcat are supposed to work. So debug is not efficient, I can't change the code and hotswap and etc.


Solution

  • IDEA supports linking Maven Projects together (with "+" button in the Maven Tool Window). If your Subprojects have direct dependencies on one another, i. e. "Subproject1" has an entry like the one below in its' pom.xml

    <dependency>
        <groupId>org.example</groupId>
        <artifactId>Subproject2</artifactId>
        <version>1.0</version>
    </dependency>
    

    IDEA will resolve them and should allow you to work on them side-by-side, without deploying JARs to Maven Repositories.