This message was deleted.
# configuration-cache
s
This message was deleted.
m
I would have bet this was CC compatible.
r
Alas
m
Does it say something in the logs?
v
https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:task_extensions
Accessing task extensions or conventions
Tasks should not access conventions and extensions, including extra properties, at execution time. Instead, any value that’s relevant for the execution of the task should be modeled as a task property.
πŸ‘ 1
m
Oh from the task action got it πŸ‘
v
I guess so, otherwise I would also have said it should work
So mainly an educated guess without the answer to your question., but my educated guesses are usually quite accurate πŸ˜„
πŸ™‚ 1
r
The specific case I'm dealing with is actually
testTask.extensions.findByType(JacocoTaskExtension.class)
I'm not sure how to model that as a property, since I don't control the definition of that type
This is a Gradle extension on a Gradle type; does Gradle itself give me a way to do this?
m
It depends where you are using
testTask.extensions
. Looks like you're using from a task action. If you control that task, and an input property there. If not, report the issue to whoever is accessing this
a
I tried to solve this for @Ryan Schmitt unsuccessfully only because the JacocoTaskExtension is not a proper Lazy Configuration enabled class. It holds onto an internalized
Property<File>
as a destinationFile but does not allow consumers full access to the property as is more commonly done. Instead it provides these three accessors/mutators.
Copy code
@Nullable
    @Optional
    @OutputFile
    public File getDestinationFile() {
        return (File)this.destinationFile.getOrNull();
    }

    public void setDestinationFile(Provider<File> destinationFile) {
        this.destinationFile.set(destinationFile);
    }

    public void setDestinationFile(File destinationFile) {
        this.destinationFile.set(destinationFile);
    }
If I need to observe the value of destinationFile but not mutate it I cannot do so in a lazy configuration way. To make matters worse I cannot set the JacocoTaskExtension as input property to another task, it is not serializable friendly.
v
because the JacocoTaskExtension is not a proper Lazy Configuration enabled class
Hopefully with Gradle 9 this changes.
If I need to observe the value of destinationFile but not mutate it I cannot do so in a lazy configuration way.
How about
testTask.map { it.jacoco.destinationFile!! }
?
a
Hmm, I always forget the
map()
option. That is a very interesting alternative. I already started on an alternate path but I will give that a shot. Thanks @Vampire
πŸ‘Œ 1