Always prefer local module source over Maven dependencies


I asked this question several months ago, and I still haven't found a reasonable way to tell IDEA to use source dependencies in preference to Maven dependencies without a great deal of busy-work manually changing poms between snapshot and release versions.

Suppose modules B and C depend on module A. Since B and C are released on a regular basis to a continuous integration/delivery environment, they never depend on a snapshot of A because any release of B and C could potentially make its way to production if it passes all the rests. In fact, module A is never published as a snapshot anywhere (nor are B and C). In other words, there are no scenarios in which either local snapshots or snapshots residing in a binary repository are used to resolve dependencies. Only versioned dependencies are used at the Maven level. Thus, when editing A, B and C together in a single IDEA project, it is necessary to tell IDEA to resolve the dependencies at the local source code (module) level rather than via Maven. Furthermore, it must do this *without* requiring B and C's poms to be updated to point to a snaphot version of A.

I have not found a way to accomplish this. If I add a module dependency on A in B and C and move it to the top of the dependency list (above the imported Maven dependencies), it is moved to the bottom of the list as soon as I close the dependencies dialog, causing the versioned Maven dependency to be preferred over the local source code for A. Moreover, even if this kind of explicit override worked, it wouldn't be ideal because it requires hard-coding B and C's dependency on A in IDEA's proprietry module system, even though the dependency relationship is already expressed in the Maven pom files. The goal is for IDEA to recognize that, although these are Maven modules, when working with them locally it should always prefer the local source code to the Maven dependencies (without requiring the poms for B and C to point to a snapshot version of A).

This is something that is easily accomplished in Eclipse by telling it to prefer local source over Maven dependencies. But in IDEA there does not appear to be a way to do this, short of going into all the poms and changing the versions and dependencies to be snapshots.

Here is another example of someone apparently trying to use IDEA in conjunction with a similar CI/CD process:


We have just reorganized our code into multiple maven projects, and are now having the same problem. It's been 2 years, any updates on this?


IDEA should resolve dependencies as a module dependency type (rather than a local jar Maven library) if this Maven project is opened in IDE and it's version matches the version, installed in a local Maven repository. If it does not work for you, please file an issue at with the sample project which shows the problem.


Thanks for the reply Andrey. You are correct, when the version numbers in the POM line up, IntelliJ will nicely convert the dependency from a maven one to a local module one, which seems like correct behavior. What I think would be most helpful would be an override setting, where we could flip a switch and have IntelliJ either respect or ignore the version number matching requirement. My Eclipse friends tell me this is a switch they have available, but I can't find an equivalent for IntelliJ.


There is no such option. Please feel free to file a request for this in YouTrack


> You are correct, when the version numbers in the POM line up, IntelliJ will nicely convert the dependency from a maven one to a local module one


This is exactly what IntellIJ is not doing for me. Started happening in 2019. IntelliJ will use maven version even if I have a version inside my project and the version matches.


The project must be imported in the same project as Maven and the Maven coordinates should match. If the requirements are met but IDE resolves dependency to a Maven library jar and not to a Maven module, please file an issue at with a sample project and idea.log.


Posting as we had the same issue.
In our case we switched
using Maven -> tomcat (plugin) configuration for running the project
using Tomcat Server configuration for running the project

No issues ever since. It appears to be always using local sources now.
Bonus: the startup time went down double.


Please sign in to leave a comment.