For me the problem when running ScalaIDE and sbt ~compile simultaneously turned out to be the fact, that both ScalaIDE and sbt used the same output directory for their compilation. This meant that they overwrote each others compiled classes and would detect them as changed resulting in new complete recompile instead of using incremental compile.
To fix it change the output directory of one of the compilers doing one of the following:
- manually edit: Project Properties -> Java Build Path -> locate the scala source folder for both, main and tests (usually [project]/src/[test/main]/scala) and edit their output folder to be something else than the default (e.g. to [project]/target/eclipse)
add to your
build.sbt
the following directive:EclipseKeys.eclipseOutput := Some("target/eclipse")
Both will change the compile output directory of the ScalaIDE compiler to [project]/target/eclipse
, where project
should be the actual name of your project directory.
As a hint how I debugged this problem, I used the last compile
command in sbt to see the logged debug information of the last compile (more about logging in sbt). From the debug info you can find out which of the sources the compiler thinks changed and which sources were invalidated by the change. It turned out, that when using the same output directory for sbt compile and ScalaIDE, they invalidated each other every time one of the ran.