This message was deleted.
# configuration-cache
s
This message was deleted.
v
That's just impossible, because all that is skipped when the configuration cache entry is reused
What you could maybe do is to abuse a
ValueSource
. Those are always evaluated and if the return a different value than before, the cache entry is not reused.
d
actually i want to disable it completely on some env variable, so i assume this type of build will never store any config cache. with
ValueSource
is it possible to disable config cache completely?
v
As I said, no. With the value source returning a UUID for example you could ensure that the CC entry will not be reused, but you cannot disable the CC. If you want to control it with some extra variable instead of the built-in, you probably need to use a custom Gradle distribution where you coded that possibility in.
d
ah got it. That type of build actually not supporting config cache because some old script we use for React native build. So even it is not reused, it will try to store new CC entry right? and most likely will failed since it is not supporting CC.
v
Indeed. Why don't you simply disable CC for that build? Does not sound like there would be situations where it should be used. Why do you need a custom property to control it?
d
So on top of our android project, we have react native build with some additional modules/gradle script on it. Those scripts not supporting config cache yet, and since it share the same gradle.properties where config cache enabled, it will failed on RN build. So i want to disable CC on RN build only.
v
Run it with
--no-configuration-cache
?
d
yes, we could do that, but then all of our RN engineers need to put that flag manually. and sometimes they use android studio, or terminal as well. We want to avoid them to change their local config manually
v
Where would you set the system property then?
And why don't you just set the
org.gradle.configuration-cache
system property to
false
?
d
we have a property on settings.gradle to define if it RN build or not. We enabled config cache on gradle.properties.
hmm is it possible to change that on settings.gradle level ?
v
Again, all that is skipped if CC is reused, so you can NOT disable CC from inside unless you use a custom distribution with the code that does it
You can NOT use an init script, a build script, a settings script or anything else in your project to dynamically disable or enable CC
As all this is skipped if CC is reused, it is too late to there do any changes
You can only control it from outside or with a custom distribution with custom code
d
custom gradle distribution you are referring to is 'gradlew' script on root folder?
v
No, custom distribution
Well, you could maybe put the logic in
gradlew
too, but that would not help you if you e.g. run from CI or IDE
The thing the Gradle wrapper downloads and runs is the distribution, the actual Gradle project code.
Similar to what is described at https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:custom_gradle_distribution, just that this approach would not help as init scripts are also skipped if CC is reused as far as I remember. So you cannot simply download the distribution and add an init script like described there, but you would need to get the source of Gradle, implement the logic you need and build the whole distribution from source.
d
v
Yes, but just in case you misread, that approach will not help you
Well, you can try whether I remember wrongly about init scripts being skipped. But even if I remember wrongly and they are run, I'm not aware of a way to disable CC from it.
d
got it thanks for your advice, i will take a look on that
👌 1