我首先删除Gradle的构建缓存
$ rm -rf $GRADLE_HOME/caches/build-cache-*
我手动确认此目录已消失。我还进行清理以确保增量构建中的任何内容都不会干扰
$ ./gradlew clean
然后我运行一个启用了构建缓存的构建:
$ ./gradlew --build-cache --scan app:assembleDebug
...
238 actionable tasks: 172 executed,49 from cache,17 up-to-date
检查生成的报告,我发现某些任务仍被标记为FROM-CACHE。这是怎么回事?
FWIW我正在使用Gradle 5.6.3。我也不使用远程构建缓存。
更新:清除构建缓存后,这是缓存目录中剩下的内容:
$ pwd
/Users/jasonatwood/.gradle/caches
$ ls -al
total 24
drwx------ 11 jasonatwood staff 352 Dec 13 18:11 .
drwxr-xr-x 9 jasonatwood staff 288 Oct 15 17:24 ..
drwxr-xr-x 14 jasonatwood staff 448 Oct 29 16:07 5.4.1
drwxr-xr-x 15 jasonatwood staff 480 Nov 26 18:25 5.6.3
drwxr-xr-x 35 jasonatwood staff 1120 Dec 11 14:14 jars-3
drwxr-xr-x 5 jasonatwood staff 160 Oct 15 17:44 journal-1
drwxr-xr-x 7 jasonatwood staff 224 Oct 15 17:50 modules-2
drwxr-xr-x 5 jasonatwood staff 160 Oct 15 17:50 transforms-2
-rw-r--r-- 1 jasonatwood staff 39 Oct 15 17:27 transforms-2.lock
-rw------- 1 jasonatwood staff 28 Oct 22 16:34 user-id.txt
-rw-r--r-- 1 jasonatwood staff 17 Dec 13 18:00 user-id.txt.lock
如果我理解正确,则不需要删除其中任何一个。