How does IDEA handle dependencies in maven project?
I have a large multimodule maven project. And when I load this project in IDEA, importing all dependencies from nexuses, making 'mvn clean install' to populate local repo, everything seems OK for maven, as it is able to resolve everything successfully. But in IDEA some classes are shown red with tooltip "cannot resolve..."
The important point is that some remote class packages are packed into 2 or more jars (instead of one as it is commonly made) with the same manifest.mf (therefore having same artifact name). They contains the same package but one keeps half of classes, and another keeps the last. The scope is compile.
It is like we have 2 classes A and B in package com.pack1 and they are packed into 2 jars foo.jar (contaning com.pack1.A.class) and foo-impl.jar (contaning com.pack1.B.class) with identical manifest.
It seems that maven handles this correctly, but IDEA doesn't: in project's structure only one jar from the jar-bundle is present (the one with no additional name parts like "-impl" or "-web"). So some classes (from the rest jars) are red, and cannot be opened through ctrl+LMB or found with ctrl-N. There is only one jar also in local m2 repo (the same from IDEA's project settings).
The magic thing is that IDEA still can find the missing class with double-shift and open the code as it is (with no decompile warning). And if I open this class in editor, scroll from source on the project structure panel doesn't work. It looks like IDEA somehow manages to load the class to classpath in memory, but doesn't know where to find corresponding jar on the filesystem.
So my question is how can it be, and how can I make IDEA and maven be friends so they behave identically when handling dependencies?
(Excepting adding missing jar to the project structure manually)
I tried reimporting on the right maven navbar, invalidating IDEA's cache, cleaning local m2 repo, reimporting the whole project from File -> new -> project from existing sources, updating repositories in Settings -> Build, Execution, Deployment -> Build Tools - > Maven->Repositories and using different maven version.
Maven 3.0.4, IDEA 17.1
Please sign in to leave a comment.
Please submit an issue at https://youtrack.jetbrains.com/issues/IDEA with the reproducible test case and we'll try to support this configuration.