Effective caching for gradle



CircleCI tries to cache artifacts. For that, it also caches the .gradle directory (see https://circleci.com/docs/how-cache-works). The issue with the current setup is that the cache is saved before gradle test runs. Thus, any dependencies fetched by gradle are not cached. Why is the caching not run after the build? In other words: Why comes the “database” phase before the “test” phase?

I know that there is a workaround (http://stackoverflow.com/questions/21814652/how-to-download-dependencies-in-gradle/27455099#27455099), but that does not work for all build dependencies fetched by gradle.

Gradle build phase

Sorry for the “me too”, but…I am wondering this as well!


I also had this problem for quite some time… finally after tons of “Download…” waits I found a snippet. You have to compile you code beforehand.

Try out:
dependencies: override: - export TERM="dumb"; ./gradlew compileTestJava cache_directories: - ~/.gradle

closed #4