Gradle caching on CI tool

Hello everyone,

I am trying to set up a project with cached gradle files. Our CI/CD tool is detecting changes on every build because gradle generates ever-changing files inside /.gradle/caches/. This means that the time saved on loading the cache is later spent on uploading the “new” cache (2 to 3 mins).

What I’m caching:

  paths:
    - ~/.gradle/caches
    - ~/.gradle/wrapper
    - .gradle/configuration-cache # experimental feature

What I’m doing before caching:

      echo "deleting ever-changing files generated by gradle because they ruin the caching"
      rm -rf ~/.gradle/caches/7.5.1/
      # seen in `gradle` docs:
      rm -f  ~/.gradle/caches/modules-2/modules-2.lock
      rm -rf ~/.gradle/caches/*/plugin-resolution/
      # delete .lock files because they might contain timestamps
      find ~/.gradle/caches/ -name "*.lock" -type f -delete
      find .gradle/ -name "*.lock" -type f -delete

I’ve also noticed that inside .gradle/caches/ there is journal-1 folder which also contains a file with a timestamp:

➜  journal-1 cat file-access.properties
#Mon Oct 17 12:59:21 CEST 2022
inceptionTimestamp=1666004361205

I am feeling like I’m in a rabbit hole, there is not enough documentation about ever-changing files (like the ones that include a timestamp) or files that are not essential for the cache computation.

Could someone please help with this? I am using Gradle 7.5.1 *

Thank you in advance!

Jen.

What you are probably after is Understanding dependency resolution