This message was deleted.
# community-support
s
This message was deleted.
j
I want to clear build cache, config cache, and project-level cache between each build. So I added to my scenario file:
Copy code
clear-configuration-cache-state-before = BUILD
    clear-project-cache-before = BUILD
    clear-build-cache-before = BUILD
But when I run gradle-profiler I'm getting an error about setting BUILD....
Copy code
Caused by: java.lang.IllegalStateException: ClearBuildCacheMutator(BUILD) is not allowed to be executed between builds with invoker Tooling API
	at org.gradle.profiler.mutations.AbstractCleanupMutator.validate(AbstractCleanupMutator.java:27)
	at org.gradle.profiler.ScenarioDefinition.validate(ScenarioDefinition.java:36)
Copy code
@Override
    public boolean allowsCleanupBetweenBuilds() {
        // Warm daemons keep caches open and thus they cannot be removed
        return !isReuseDaemon();
    }
how can I clear caches between builds and reuse the Gradle Daemon?
g
I believe you can't. I don't understand what motivated this limitation. There's an open issue about improving the error message, but not one about lifting it.
a
Daemon keeps caches open (as comment indicates 🙂), which basically means it holds file locks for caches open. It might even keep some things in the memory. So if you try to clean cache: either clean will fail or retrieving from cache could fail or return some stale data.
til 1
j
I want to benchmark by builds without using any of the project-cache or build cache. Presumably I want to clear these before every iteration. But I do want to capture the benefit of re-using the daemon.
I realized that what I really need is to use --rerun-task and --no-configuration-cache, instead of using the profiler flags
Copy code
package-universal-apk {
    title = "Package universal apk"
    tasks = ["app:packageInternalDebugUniversalApk"]
    warm-ups = 2
    iterations = 5
    cleanup-tasks = ["clean"] # run before each build
    gradle-args = ["--rerun-tasks", "--no-configuration-cache"]
}
g
For that intent, yes. Also, since you're using
--rerun-tasks
, you don't need
clean