Travis CI and Gradle caching


(Aleksey Kladov) #1

Hi! How should .travis.yml caching config look like, so that Travis does not repack caches after each and every build?

Currently Travis docs suggest to do:

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

(the rm bits most recently updated by me in https://github.com/travis-ci/docs-travis-ci-com/pull/611).

However, with Gradle 4.0 I see thrashing again because of these two files:

/home/travis/.gradle/caches/4.0/fileHashes/fileHashes.bin
/home/travis/.gradle/caches/4.0/fileHashes/fileHashes.lock

Could someone with better understanding of Gradle internals comment, what exactly should be cached on CI (that is, which files almost never change)?


(Aleksey Kladov) #2

Ok, so now I am using

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
  - rm -f  $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
  - rm -f  $HOME/.gradle/caches/*/fileHashes/fileHashes.lock

which seems to do the trick, but I am not sure if I am accidentally deleting to much stuff.