Thought it may be useful to share this info to the community.
We have a Java-based packaged binary (JAR file) and this gets pulled via wget on every build as external tool/dependency in dependency step. This binary gets run in the test step and at runtime, it pulls in it’s needed dependencies (Java jars) into $HOME/.m2 (looks to be maven repo). But I notice that during each build (excluding 1st build), it still pulls dependencies rather than it being cached between CircleCI builds. Per your docs, it sounded like maven local repos are automatically cached. And just in case, I added $HOME/.m2/ to the cache_directories section of dependencies section. With or without the specific cache_directories entry, every build still pulls the dependencies and not read from cache. What am I doing incorrectly? Or is the cache only cached upon successful builds? Because my past builds have been failing due to known failures.
(NOTE: I haven’t since followed up on this yet as work on that repo has been shelved for the time being)
Response from Alexey at CircleCI:
The dependency cache is saved right after the dependencies step on each build—so if Maven actually downloads those files during the test step, it makes sense that they didn’t get cached. We still haven’t figured out how to make Maven cache all those dependencies, but one suggestion would be to do the following in your circle.yml:
- mvn --fail-never dependency:go-offline || true
Could you please check if this actually pulls all the dependencies and stores them in ~/.m2?