sbt-build has eviction bug / duplicate libraries


there is a severe problem with the built-in sbt compilation / dependency-model. I have a library A that is published with a dependency on library B version 1.7.0. Now I have an application C that depends on A but wants to use a newer minor version of B, version 1.7.2-SNAPSHOT. When I compile and run my project from the terminal directly with sbt, there is no problem. I have 1.7.2-SNAPSHOT on the class path.

But IntelliJ IDEA keeps two versions around, both 1.7.0 and 1.7.2-SNAPSHOT apparently (see attached screen shot). At runtime this causes the old version to be loaded by the class loader somehow, breaking my code. The step debugger also shows the source code of 1.7.2-SNAPSHOT but hightlights the wrong lines, apparently referring  to the binary of 1.7.0. The problem persists if I create a version 1.7.2 (non-snapshot), then I have still 1.7.0 and 1.7.2.

This problem is very severe, because even if I delete the .idea folder and re-import my project from scratch, I end up with all the concurrent minor version jars on my class-path. So the only solution is really to go back from built-in sbt build to the sbt-plugin for IDEA, until this issue is resolved :(

Screenshot from 2015-01-02 18:12:13.png
Screenshot from 2015-01-02 17:58:49.png

I have a theory of the origin of this problem.

Actually my project C is a multi-module project. It has sub-modules -core and -views with the latter dependening on (/ extending) the former. -core depends on A, whereas -views depends on the B (the library that appears in two versions). Now v1.7.0 ends up on the class path of -core (because it only depends on A which defined the transitive dependency on B v1.7.0), and v1.7.2 ends on the class path of -views (because it has an explicit dependency on that newer version). My theory is that when I run the -views project, IntelliJ IDEA accidentally throws together all the jars of the sub-modules without applying a proper eviction scheme!


Hi! Thanks for the report.

Unfortunately, you're correct: there is no eviction performed in IDEA when building project. We're thinking about proper solution for this problem. You can watch its progress on Youtrack