I am working to reduce the compile time for my build. Locally, SBT caches incremental compilations so that only files that are changed are re-compiled between builds. On circle ci, however, every build compiles all my source code, which takes 5 minutes.
I’ve tried adding this to my circle.yml, to no avail:
dependencies:
cache_directories:
- "~/.iv2"
- "~/.sbt"
- "target"
- "project/target"
I get this error:
sbt.InvalidScalaInstance: Scala instance doesn't exist or is invalid:
version 2.11.8, library jar: /home/ubuntu/my_project/lib_managed/jars/org.scala-lang/scala-library/scala-library-2.11.8.jar, compiler jar: /home/ubuntu/my_project/lib_managed/jars/org.scala-lang/scala-compiler/scala-compiler-2.11.8.jar
Has anyone been able to successfully cache incremental compilation from sbt so that on the next build only re-compiles the modified files?
------------------------------------------------SOLUTION----------------------------------------------------------------------------------
I added this to circle.yml and it worked. Reduced my compile time to 44s.
dependencies:
cache_directories:
- "~/.iv2"
- "~/.sbt"
- "lib_managed" #### <-- need this
- "target"
- "project/target"