How to Cache SBT Dependencies

scala
sbt
caching

#1

I’m trying to cache the dependencies for my SBT project. I have the following configuration, as per the sample documentation for sbt:

  cache_directories:
    - "~/.ivy2"
    - "~/.sbt"```

But none of the dependencies seem to be getting cached; they are all being downloaded in each build. Is there something else I can change to prevent needing to download the dependencies in each build?

#2

@alexblickenstaff any finding for that?? I am having the same issue with sbt + docker


#3

Unfortunately I never found a solution for this. This was a while ago, but I believe I switched to Travis CI. There’s a page explaining SBT caching on Travis CI here.


#4

This appears to have fixed it. Here is my entire circle.yml file:

machine:
  java:
    version:
      oraclejdk8

general:
  artifacts:
    - target/universal

dependencies:
  cache_directories:
    - "~/.iv2/cache"
    - "~/.sbt"
    - "~/.m2"
    - "target/resolution-cache"
    - "target/streams"
    - "project/target/resolution-cache"
    - "project/target/streams"
  override:
    - sbt compile

test:
  override:
    - echo "No tests to run"

deployment:
  prod:
    branch: master
    commands:
      - ./deploy.sh



#5