Slackbot
10/04/2022, 1:51 AMChris Lee
10/04/2022, 1:52 AMCalculating task graph as configuration cache cannot be reused because file '../../../../.cloudshift-gradle/.cloudshift-codeartifact.properties' has changed.
…all that code is inside a single ValueSource.Chris Lee
10/04/2022, 1:53 AMVampire
10/04/2022, 1:55 AMChris Lee
10/04/2022, 1:57 AMValueSource
docs hint that it’s only reading:
A value source implementation is exempt from the automatic detection of work graph cache inputs. For example, if theThat file is used in one class (read and write), buried way down deep inside a ValueSource call hierarchy.method callsobtain()
then changes to theSystem.getenv("FOO")
environment variable only invalidate the cache if the value returned by theFOO
method itself changes. The same applies to reading files or system properties.obtain()
Chris Lee
10/04/2022, 1:58 AMChris Lee
10/04/2022, 2:11 AMorg.gradle.internal.classpath.InstrumentingTransformer
, Not seeing anything for writing in there. It’s possible that the pattern being used to read/write isn’t properly caught by the instrumentation.Chris Lee
10/04/2022, 5:50 AMproviders.environmentVariable
or providers.gradleProperty
as an input parameter to another ValueSource.
In digging through the internals, the logic works as:
a) Transforming classloader (org.gradle.internal.classpath.InstrumentingTransformer
) - finds all kinds of relevant code (such as file open, get env variable, etc) and rewrites the code to emit events
b) event handler (org.gradle.configurationcache.fingerprint.ConfigurationCacheFingerprintWriter
) stores these changes _conditionally_; the conditional is based on a ThreadLocal variable inputTrackingDisabledForThread
c) when a value is obtained from a ValueSource, it first emits a beforeValueObtained()
event; this sets the input tracking OFF
d) value is obtained from ValueSource
e) ValueSource emits afterValueObtained()
event; this sets the input tracking ON
The problem comes when using a ValueSource (such as a Gradle property) as an input parameter to your ValueSource (it may be if there are an odd-number of ValueSource parameters) - the fingerprinting of those inputs resolves the values, and leaves input tracking ON for the body of your ValueSource. Ouch.
Will get the repro cleaned up and an issue created in the morning.Chris Lee
10/04/2022, 6:07 AMChris Lee
10/04/2022, 6:14 AMVampire
10/04/2022, 10:18 AM