Slackbot
01/11/2024, 4:57 PMMartin
01/11/2024, 5:03 PMRyan Schmitt
01/11/2024, 5:43 PMMartin
01/11/2024, 5:44 PMVampire
01/11/2024, 5:50 PMAccessing 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.
Martin
01/11/2024, 5:50 PMVampire
01/11/2024, 5:50 PMVampire
01/11/2024, 5:52 PMRyan Schmitt
01/11/2024, 6:06 PMtestTask.extensions.findByType(JacocoTaskExtension.class)
Ryan Schmitt
01/11/2024, 6:06 PMRyan Schmitt
01/11/2024, 6:06 PMMartin
01/11/2024, 6:15 PMtestTask.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 thisAlexander Volanis
01/12/2024, 2:01 PMProperty<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.
@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.Vampire
01/12/2024, 2:07 PMbecause the JacocoTaskExtension is not a proper Lazy Configuration enabled classHopefully 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!! }
?Alexander Volanis
01/12/2024, 2:54 PMmap()
option. That is a very interesting alternative. I already started on an alternate path but I will give that a shot. Thanks @Vampire