Gradle cache corruption in Jenkins

Hi,

Apache Kafka uses Gradle as its build system and the project includes both Java and Scala code. We have been struggling with frequent Gradle cache corruption issues in Jenkins. It seems to happen more often during the javadoc task and deleting the project-local .gradle directory before each build seems to help, but it doesn’t fix it completely. We have experienced the issue in 2 separate Jenkins instances (one of them using the Jenkins Gradle plugin). A few examples of the problem follows:

Failed to capture snapshot of input files for task 'compileJava' during up-to-date check.
> Could not add entry '/home/jenkins/.gradle/caches/modules-2/files-2.1/net.jpountz.lz4/lz4/1.3.0/c708bb2590c0652a642236ef45d9f99ff842a2ce/lz4-1.3.0.jar' to cache fileHashes.bin (/home/jenkins/jenkins-slave/workspace/kafka-trunk-jdk7/.gradle/2.13/taskArtifacts/fileHashes.bin).

https://builds.apache.org/job/kafka-trunk-jdk7/1346/console

Failed to capture snapshot of input files for task 'compileJava' during up-to-date check.
> Could not add entry '/home/jenkins/.gradle/caches/modules-2/files-2.1/net.jpountz.lz4/lz4/1.3.0/c708bb2590c0652a642236ef45d9f99ff842a2ce/lz4-1.3.0.jar' to cache fileHashes.bin (/home/jenkins/jenkins-slave/workspace/kafka-trunk-jdk7/.gradle/2.13/taskArtifacts/fileHashes.bin).

https://builds.apache.org/job/kafka-trunk-jdk7/1344/console

Failed to capture snapshot of output files for task 'javadoc' during up-to-date check.
> Could not add entry '/home/jenkins/workspace/kafka-trunk/clients/build/docs/javadoc/serialized-form.html' to cache fileHashes.bin (/home/jenkins/workspace/kafka-trunk/.gradle/2.13/taskArtifacts/fileHashes.bin).

https://jenkins.confluent.io/job/kafka-trunk/908/console

The last example above happened even though we deleted /home/jenkins/workspace/kafka-trunk/.gradle before executing Gradle.

Gradle Version: 2.13 and earlier
Operating System: Linux and Mac
Is this a regression? No

Link to Gradle build: https://github.com/apache/kafka/blob/trunk/build.gradle

Any help would be appreciated.

Thanks,
Ismael