matklad
(Aleksey Kladov)
June 27, 2017, 8:09am
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)?
1 Like
matklad
(Aleksey Kladov)
August 9, 2017, 10:06pm
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.
2 Likes
G00fY2
(Thomas Wirth)
March 22, 2019, 5:55pm
3
I have the same question. From my understanding the *.lock files are just helpers to prevent gradle from modifying the cache while in usage (can be totally wrong).
Any idea if removing the following files from my cache before saving has any negative impact?
/.gradle/caches/4.10.1/fileHashes/fileHashes.bin
/.gradle/caches/4.10.1/fileHashes/fileHashes.lock
/.gradle/caches/4.10.1/javaCompile/javaCompile.lock
/.gradle/caches/journal-1/file-access.bin
/.gradle/caches/journal-1/journal-1.lock
/.gradle/caches/transforms-1/transforms-1.lock
Edit
Found out that bitrise seem to use these exclude patterns :
excludePths := []string{
"~/.gradle/**",
"~/.android/build-cache/**",
"*.lock",
"*.bin",
"/**/build/**.json",
"/**/build/**.html",
"/**/build/**.xml",
"/**/build/**.properties",
"/**/build/**/zip-cache/**",
"*.log",
"*.txt",
"*.rawproto",
"!*.ap_",
"!*.apk",
}
Is this a valid approach or do they exclude too much information for gradle caching to work?