Hi everyone Does anyone know if you can pre-genera...
# configuration-cache
d
Hi everyone Does anyone know if you can pre-generate configuration-cache for a task (
test
for example) without actually running it?
m
Not an official endorsement, but you can run the build with
--dry-run
to prime the configuration cache. The actual cached build may still fail, if tasks are doing something funny in their actions like calling
getProject()
Out of curiosity, what workflow do you have in mind? Setting up a CI agent?
d
Hi, thanks for the quick reply! I tried both with --dry-run and --test-dry-run and in both cases im seeing it can't resuse
task graph as no cached configuration
and yes the use case is related to caching the configuration-cache for the next-job
m
As this is not something we're aiming at today, there can be corner cases. I'm somewhat surprised, though, that CC cannot find the cached configuration at all. In my test project with Gradle 8.14.3
--dry-run
works fine. If you're testing in the CI environment, I would check if the cache entry is properly restored. Or you can check locally first.
d
Interesting, will take a look. Im using nix to build by package so the builds should be pretty reproducible but maybe i am missing something. I just assumed that tasks must actually run because cache entrires contain the task outputs or something
m
Configuration cache only stores task configuration, it doesn't look at inputs/outputs - that's the responsibility of the build cache. The only situation where it matters is for build logic pieces - Gradle compiles build scripts and included plugins, and also transforms build logic dependencies (like third party plugins). These typically end up in the build cache, but the cached configuration references them too. One thing that can affect is that the command lines for the "seeding" build and the actual build must be identical with
--dry-run
being the only difference. Basically, everything that is in the command-line affects the lookup, except for some switches that Gradle core itself processes. For example,
--dry--run
is consumed by the core, so it isn't part of the configuration cache "key".
--test-dry-run
is configuring the test task you're specifying in the command-line, so it is part of the "key" and adding/removing it will cause
no cached configuration
.
d
Got it, so i was screwing myself over with trying to be smart about it. Thanks for the insights!