Is there an annotation by which I can opt-out a cu...
# community-support
s
Is there an annotation by which I can opt-out a custom task from being compatible with the configuration cache?
Oh, it's probably
@DisableCachingByDefault
... I was just confuse that it stimm emits the "1 problem was found storing the configuration cache" message.
p
That’s about the build cache
s
Yeah, I knew about
notCompatibleWithConfigurationCache()
, but that still prints the above message. So I wanted to know about an annotation that behaves as if
--no-configuration-cache
was passed on the CLI and suppresses the message.
v
Afair there is not. The annotation as Philip mentioned is for build cache and has nothing to do with configuration cache. The
notCompatibleWithConfigurationCache()
is just meant as temporary measure during migration to CC-compatibility. Having a task with that option in the task graph will still log the problem as warning but not immediately fail the build due to the found problem. But still the build could fail or behave strangely depending on the actual found problem, because iirc since some 8.x version even the initial run of a task with CC does not use the currently freshly created task state, but instead create the CC state, deserialize the CC state and use that deserilized CC state to run the build, as otherwise there could be strange behavior changes between the run that creates the CC state and the run that reuses the CC state. So iirc the technical details even with that option the build could - and in most cases will - behave strange or bad, and the option just prevents the CC state to be stored for reuse at the end of the build.
Before that change in 8.x that the CC state is even used on the run producing the CC state, the option would have caused the build to work despite the warnings as the freshly generated state was used instead of the CC state. Maybe a feature request should be posted to again use that strategy if such a task is in the task graph. Unless of course I remember wrongly and that is already happening. 🙂
No, I seem to be wrong. 🙂
Copy code
val bar = "asdf"
val foo by tasks.registering {
    //notCompatibleWithConfigurationCache("foo")
    doLast {
        println("foo: $bar")
    }
}
with
--configuration-cache-problems=warn
fails due to
Cannot invoke "Build_gradle.getBar()" because "this.this$0" is null
, as the CC state is reused, but without
--configuration-cache-problems=warn
and commenting
notCompatibleWithConfigurationCache("foo")
it properly prints, so it seems the original state is used as it should be, but still the warnings are displayed and I don't think you can suppress that.