Preserve results of sbt incremental compilation when moving project directory

241 views Asked by At

Consider the scenario: I have a simple scala project managed by sbt, in a directory called foo.

cd foo
sbt compile

It now takes a few seconds and the project compiles correctly.

Now, thanks to sbt incremental compilation, if I run

sbt compile

it terminates the compile task in close to 0 seconds, since the source code hasn't changed.

But if I rename the foo directory into bar

cd ..
mv foo bar

and try to compile it again

cd bar
sbt compile

now the compile task takes again few seconds, hence not using the results from the previous compilation.

Is there a way to preserve the incremental compilation results of a project even when its absolute path on disk has changed?

2

There are 2 answers

0
Gabriele Petronella On

As it turns out, there's some work in progress to make incremental compilation results cacheable. Here's the relevant PR: https://github.com/sbt/zinc/pull/216.

Also, there's an issue (being discussed at the time of this writing) about making zinc's analysis completely machine independent. See https://github.com/sbt/zinc/issues/218.

1
romanowski On

You can also try to use Hoarder Plugin: https://github.com/romanowski/hoarder.

Ping me on Hoarder's gitter in case of any questions/problems.