This message was deleted.
# configuration-cache
s
This message was deleted.
a
They need to be "isolatable", which means Gradle needs to be able to ensure that the values can be safely used in parallel. If Gradle knows the value is immutable, it will use the value as-is. Otherwise, Gradle will make a copy. For some types, for example
ArrayList
or
Provider<T>
it knows how to do this efficiently. For everything else, it will just serialize the value.
r
Is there some annotation I can use to make Gradle use the value as-is? Can I somehow convey that the inputs and outputs are thread-safe?
Also, if a
ValueSource
is known to provide an input to configuration, doesn't that mean the value it yields must be serializable? Doesn't the CC entry have to be discarded if
ValueSource::obtain
changes from the serialized value?
a
Is there some annotation I can use to make Gradle use the value as-is?
There is not. We're not super keen on adding such a thing, as it's pretty error prone, but it's certainly an option. Do you have an example of a type you'd like to opt-in, where serialization is problem?
doesn't that mean the value it yields must be serializable?
It depends what "serializable" means. It doesn't need to implement Java
Serializable
, but it will be serialized (ie turned into bytes) using the CC infrastructure.
r
Do you have an example of a type you'd like to opt-in, where serialization is problem?
@adam I have to integrate with a legacy build system that runs an external process to find, start (if necessary), and connect to a localhost daemon. This is proving quite difficult to do in a way that is compatible with configuration caching
I'm currently doing this by smuggling the connection object through a static field in a
ValueSource
which initializes said field upon construction
m
So you have to use the
ValueSource
because of the external process, right? Is this process/connection used at configuration time? I'm asking because this is sometimes a proxy for "start the process always regardless of which tasks are being invoked", and a better API can be designed for that use case.
r
Yes, configuration time