Changes to external Java library not picked up by compiler?
I'm having an odd issue in IDEA 14, and I hope it's just something I'm not understanding. I've got a Java project with external libraries (which are actually Maven dependencies). Now in some cases, if I update a dependency, I may get a compiler error in a file. For example, it may say that I'm trying to pass type X to a method expecting type Y. Further, assume the method is on a class that's contained in the Maven dependency.
This is where it gets weird. If I click on the method and jump to the source (which is in the external JAR), the type for the method argument is correct. But for some reason, my source file still has an error flag saying the type is wrong. I've tried doing a Synchronize on the file, the module, and even on the external JAR in the library section of the project tree. I also tried using the Maven panel to compile, do a clean/install, reimport the module, and even reimport all modules. The only thing that seems to occasionally work is shutting down IDEA completely and then restarting it. At that point, it does something (a re-index?) which finally gets rid of the error.
Is this normal? Is there some trick here to get IDEA to really pick up a change in an external library? The only things I've haven't tried yet are Make Module and Rebuild Project, which I'll try the next time this happens. However, that seems kind of extreme for something that sounds like it should "just work". I feel like I'm missing something here. Any help appreciated.
Thanks,
Brian
Please sign in to leave a comment.
Hi Brian,
I'm using IDEA for a very large project with tens (~20) of maven modules. From time to time I get similar problem, which always is being resolved as I reimport the module (Maven/Reimport).
Are your modules imported from maven (.pom) files and is maven build successful, although an error is present in the editor?
Ivaylo
Yes, exactly. The IDEA modules are imported via POM, and I can build via Maven successfully, even though the IDE says there's an error. But if I try to, say, run a unit test within the IDE, that will fail. So it's like Maven is seeing the updated external dependency as it should be, but the IDE is stuck thinking the module I'm working on is looking at the old dependency. And again, I can even jump to the dependency JAR source and see that it is correct. Reimporting the Maven modules doesn't seem to help. Only a full restart of IDEA seems to do it, and even that seems to be hit or miss (I'm not sure what conditions trigger IDEA to actually reindex).
I was hoping this was a case where someone would say "oh yeah, just do so-and-so", but it sounds like this is more convoluted than that. And since there's really no IDE error, I can't provide JetBrains with much beyond what I'm describing. :-/
I would try deleting the dependencies caches that IDEA makes in C:\<USER_HOME_FOLDER>\.IntelliJIdea<VERSION>\system
I can not remember right now which was the exact folder - chaches, index, jars or other ...
Well, IDEA has an option to purge its indexes, but that nukes everything for all projects. That's pretty extreme and I see it as a last resort. If/when it pops up again, I plan to try using Make Module and Rebuild Project.
Thanks,
Brian
Hi,
I still have exactly this problem with the latest IntelliJ Build (Ultimate 2016.3.4). It "feels" like this problem mainly occurs after closing a project and opening another.
What I usually can do:
What I have tried/notcied
Any ideas what could cause the problem?