Recommended directories to save/restore as cache in CI/CD

GitLab CI and the like provide a way to configure which directories are treated as cache, so that they will be restored before build and saved after build, in order to make consecutive jobs/pipelines more efficient. As per the documentation, it seems some directories are worth saving/restoring:

  • $GRADLE_USER_HOME/caches: Global cache directory (for everything that is not project-specific).
  • $GRADLE_USER_HOME/jdks: JDKs downloaded by the toolchain support.
  • $GRADLE_USER_HOME/wrapper/dists: Distributions downloaded by the Gradle Wrapper.

How about other directories within $GRADLE_USER_HOME and {PROJECT_ROOT_DIR}/.gradle and all builds within {PROJECT_ROOT_DIR}? What directories are recommended to save/restore in CI?