Hi,
I am trying to understand the behaviour of the build-cache in contast to the (so-called) “project-cache”.
Due to the discussion in my previous topic and I managed to enable incremental build and skip fetching proto-files from another repistory to fully skip the process of generating (java-) code from the proto files.
Thus, I am a bit confused about the following behaviour: After cleaning up, i.e., executing ./gradlew clean, I understand the following behaviour:
$ ./gradlew build --console=verbose --no-daemon -Duser.language=en
> Task :protobufDummy UP-TO-DATE
> Task :extractIncludeProto
> Task :extractProto
> Task :fetchProtoFiles
Cloning into '***\multi-project\build\cloned'...
> Task :generateProto
> Task :compileJava
> Task :processProtoResources
> Task :processResources
> Task :classes
> Task :resolveMainClassName
> Task :bootJar
> Task :jar
> Task :assemble
> Task :extractIncludeTestProto
> Task :extractTestProto
> Task :generateTestProto NO-SOURCE
> Task :compileTestJava NO-SOURCE
> Task :processTestProtoResources
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :build
BUILD SUCCESSFUL in 9s
13 actionable tasks: 13 executed
$ ./gradlew build --console=verbose --no-daemon -Duser.language=en
> Task :protobufDummy UP-TO-DATE
> Task :extractIncludeProto UP-TO-DATE
> Task :extractProto UP-TO-DATE
> Task :fetchProtoFiles SKIPPED
> Task :generateProto UP-TO-DATE
> Task :compileJava UP-TO-DATE
> Task :processProtoResources UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :resolveMainClassName UP-TO-DATE
> Task :bootJar UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :assemble UP-TO-DATE
> Task :extractIncludeTestProto UP-TO-DATE
> Task :extractTestProto UP-TO-DATE
> Task :generateTestProto NO-SOURCE
> Task :compileTestJava NO-SOURCE
> Task :processTestProtoResources UP-TO-DATE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :build UP-TO-DATE
BUILD SUCCESSFUL in 5s
Thus, after the first run, the local project-cache is built and in the second run, fetchProtoFiles can be SKIPPED due to the onlyIf closure and thus generateProto is UP-TO-DATE.
However, now I try the same with caching.
I do
./gradlew clean./gradlew build --build-cache -Duser.language=en --console=verbose --no-daemon(which leads to the folderbuild-cache-1in im gradle home directory./gradlew clean./gradlew build --build-cache -Duser.language=en --console=verbose --no-daemon
And now I am confused
$ ./gradlew build --build-cache -Duser.language=en --console=verbose --no-daemon
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/9.3.0/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :protobufDummy UP-TO-DATE
> Task :extractIncludeProto
> Task :extractProto
> Task :fetchProtoFiles
Cloning into '***\multi-project\build\cloned'...
> Task :generateProto FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :processProtoResources
> Task :processResources
> Task :classes
> Task :resolveMainClassName
> Task :bootJar
> Task :jar
> Task :assemble
> Task :extractIncludeTestProto
> Task :extractTestProto
> Task :generateTestProto NO-SOURCE
> Task :compileTestJava NO-SOURCE
> Task :processTestProtoResources
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :build
BUILD SUCCESSFUL in 8s
Why is fetchProtoFiles not retrieved from cache, i.e., not attributed with FROM-CACHE? Even stranger, the task generateProto, which depends on that, is retrieved from cache?
Thus, due to the local project-cache, this task can be skipped, but with build-cache it is not possible to do so? ![]()