Maven multi module pom dependencies between modules

We have a multi module pom with a top level project that has two child jar modules, where the second child module has a dependency on the first child module's jar (in the dependencies section of the pom).

IntelliJ correctly creates the module structure, but the second module gets a dependency on the maven repo jar instead of a module dependency on the first IntelliJ module. This means that changes made in the first jar module are not available in the 2nd jar module, because it is using the jar from the maven repo instead of the compiled classes from the first module. The simple solution is to manually add a module dependency to the 2nd jar module. But every time the pom changes it is reimported and this dependency disappears.

Do anyone have any advice how to construct a multi-module project in a way that IntelliJ will interpret it as a module dependency instead of a maven repo dependency?

Any help would be appreciated.

Please sign in to leave a comment.