I have a data object I would like to create for an...
# community-support
z
I have a data object I would like to create for an extension.
Copy code
interface ArtifactoryPublisherPublishDetails : Named {
    val group: Property<String>
    val version: Property<String>
    // Should be in a folder `artifactId`/`filename`
    // this is just the file name
    val files: ListProperty<String>
}
However, when I access anything in this interface, I get the following exception:
Copy code
Receiver class Build_gradle$ArtifactoryPublisherExtension$ArtifactoryPublisherPublishDetails$Impl does not define or inherit an implementation of the resolved method 'abstract org.gradle.api.provider.Property getGroup()' of interface Build_gradle$ArtifactoryPublisherExtension$ArtifactoryPublisherPublishDetails.
usage:
Copy code
val artifactId: String = // ..
val publishDetails: ArtifactoryPublisherPublishDetails = objects.named<ArtifactoryPublisherPublishDetails>(
    "${artifactId}ArtifactoryPublisherPublishDetails"
)

publishDetails.group // this line throws
Should what I’m trying to do work?
correct way to dothis is:
Copy code
val publishDetails: ArtifactoryPublisherPublishDetails = objects.newInstance<ArtifactoryPublisherPublishDetails>()
and drop the
Named
inheritance
t
Note that if you want it
Named
(could be useful for debugging) then you have to explicitly implement the interface and pass the value generally to the constructor (through an argument to
newInstance
), unless the name is a constant of course.
💯 1