Hey there i have a question regarding ignoring cer...
# configuration-cache
r
Hey there i have a question regarding ignoring certain build parameter in configuration cache. We generate a random test seed that we pass to a TestTask. With configuration cache enabled this stays the same for the whole time the cache is reused. I see multiple discussions around having the option to ignore certain properties from the configuration cache explicitly in github issues but those have not been addressed for years (e.g. https://github.com/gradle/gradle/issues/20873) Did i miss a memo here? What do people do these days having this type of requirement? just not using the configuration cache?
m
Postponing provider API migration didn't help our ability to wire things in a CC-compatible way :( Besides that, we're looking into making Credentials more CC-friendly, but I doubt we'll ever do any kind of blanket exclusions being requested there. Passing the random seed seem to be the opposite of being described in the issue though - you're getting false hits while you want the seed to change. Ignoring it won't help, as it doesn't come from the outside, as far as I understand. How do you pass the seed to the test task? Through a system property? If so, a combination of a
ValueSource
to produce the value and a
CommandLineArgumentProvider
to supply it lazily to the test JVM process will do the trick.
r
is there a way to track down whats triggering this
Copy code
Calculating task graph as configuration cache cannot be reused because a build logic input of type 'TestSeedValueSource' has changed.
in our build? I can see passing a valuesource directly to the test task this works. but we have a central place to have one seeed per build. is there tooling to track down a sort of stacktrace here?
m
Today you can attach a debugger to the Gradle daemon running a cache miss build to set a breakpoint in the
TestSeedValueSource.obtain
. I would do
rm -rf .gradle/configuration-cache
first to skip hitting the breakpoint when checking the fingerprint. There is also a (rather imprecise) location in the configuration cache report under `Build configuration inputs`/`value from custom source`.
r
I think i found it. eww printing to commandline at configuraton phase triggered it ¯\_(ツ)_/¯
👌 1
its so easy to mess this up 😢 😂
v
Is it? 😄 If you use it at configuration time, it is CC input, so you get a miss if the value changes. If you only use it at execution time, it is not. Sounds probably much simpler than it actually is. 😄
r
i mean if it sneaks into configuration time its hard to force this failing.
We run into this problem every once in a while when i wish i can enforce certain apis and enforce not using other apis / functionality. but thats a general thing, not only when it comes for dealing with configuration caches
v
You probably need to use some linter that supports configurable or custom rules to enforce your rules I guess
r
yes
we use forbidden apis downstream but we wrote our own gradle integration as the shipped plugin is 💩 . I remember i also worked on a gradle linter like 10 years ago to check if i can forbid statements like if or while loops in build scripts. but that was very tight bound to groovy ¯\_(ツ)_/¯
v
Use dcl 😄
r
I'm not bored enough to go down that painful rabbit hole with our build yet 😄 . We have enough half ass apis we need to juggle with already. just run into this today 🤣
Copy code
/** @deprecated */
    @Incubating
    @Deprecated
    public boolean isConfigurationCacheRequested() {
        StartParameterDeprecations.nagOnIsConfigurationCacheRequested();
        return false;
    }