I am currently developing a Gradle plugin in Java. I am trying to use a ListProperty to represent multiple values in block-style YAML. I want the configuration via the build.gradle file to be as simple as possible, something along the lines of:
taskName {
yamlAttribute { //This is the ListProperty
listValueOne,
listValueTwo,
...
}
}
I did not find any threads on whether this is possible at all or not. If it is not, what would other ways be to approach this?
I don’t think with the commas it is valid Groovy syntax, so it cannot be done.
Without the commas it should be possible, with some Groovy tricks like having there an action that has as target a Groovy object that handles missing properties in such a way that it adds the values to the list property.
But be aware that such a solution will be very Groovy specific and then is most probably only nicely usable with Groovy DSL. Sane people that use the Kotlin DSL or any other DSL that comes up in the future will probably curse you for that.