Robert Elliot
11/08/2024, 12:25 PMRobert Elliot
11/08/2024, 12:31 PMgroovy.lang.MissingPropertyException: No such property: name for class: org.gradle.api.internal.file.DefaultFileCollectionFactory$ResolvingFileCollection
at net.idlestate.gradle.duplicates.CheckDuplicateClassesTask$_checkForDuplicateClasses_closure3.doCall$original(CheckDuplicateClassesTask.groovy:71)
at net.idlestate.gradle.duplicates.CheckDuplicateClassesTask$_checkForDuplicateClasses_closure3.doCall(CheckDuplicateClassesTask.groovy)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at jdk.proxy2/jdk.proxy2.$Proxy155.apply(Unknown Source)
at java_util_stream_Stream$collect.call(Unknown Source)
at net.idlestate.gradle.duplicates.CheckDuplicateClassesTask.checkForDuplicateClasses(CheckDuplicateClassesTask.groovy:70)
The offending line of code can be seen here: CheckDuplicateClassesTask.groovy#L71
What's odd is that DefaultFileCollectionFactory.ResolvingFileCollection does not implement org.gradle.api.artifacts.Configuration. If it did it would also implement org.gradle.api.Named and so would have a property name.
If I disable the configuration cache all is good. So presumably enabling the configuration cache somehow provides a DefaultFileCollectionFactory.ResolvingFileCollection to the task instead of a org.gradle.api.artifacts.Configuration which seems really unexpected...Vampire
11/08/2024, 12:39 PMConfiguration has, it is a Configuration.
So even if it does not formally declare that it is Configuration or Named, as long as it responds to the name property, it can be used.
Without the CC, it probably directly is a Configuration and thus name works.
With CC the configuration is serialized as FileCollection and then deserialized as FileCollection which then no longer responds to name.Robert Elliot
11/08/2024, 12:44 PMConfiguration to something that did not contain a getName? It seems a very small bit of extra data to serialize, and Named a pretty fundamental interface to throw away.Robert Elliot
11/08/2024, 12:45 PMVampire
11/08/2024, 12:50 PMNamed.
And it is not that they "serialize Configuration as something else".
If you for example have a Property<Configuration>, CC will yell at you that Configuration is not CC-compatible.
But a Configuration also implements FileCollection.
So if you have a Property<FileCollection> (of course you would normally use a ConfigurableFileCollection where you set from on, just to explain the technical part),
then you can set it to a Configuration instance.
But you declared you need a FileCollection and that is what is serialized and deserialized.
Using name although you declared that you take any FileCollection is like casting to Configuration and getting name or using reflection to get name.
You can do that in any JVM language and by just using name in Groovy you basically do the same.
But it will only work if the FileCollection really is a Configuration instance.
If you put in any other FileCollection, including a the deserialized one from the CC entry, it fails due to reflection not finding the method or the cast not succeeding or the respective property not found in Groovy.Vampire
11/08/2024, 12:51 PMRobert Elliot
11/08/2024, 1:05 PMBut you declared you need aWhen?FileCollection
Vampire
11/08/2024, 1:06 PMVampire
11/08/2024, 1:08 PMVampire
11/08/2024, 1:08 PMRobert Elliot
11/08/2024, 1:09 PMVampire
11/08/2024, 1:09 PMVampire
11/08/2024, 1:10 PMRobert Elliot
11/08/2024, 2:07 PM