This message was deleted.
# plugin-development
s
This message was deleted.
1️⃣ 2
2
c
Assuming you’re referring to a custom task, the property type for a file would generally be RegularFileProperty.
j
It is indeed about a custom task or an extension, but configurable by the end-user.
c
a few options: -have the user directly supply the file, e.g. prop.set(file(“someFile.txt”)) -hide some of that from the user e.g. prop.set(“someFile.txt”) for the extension (as a String), and then taskProp.set(prop.map { layout.projectDir.dir(it))})
j
Asking for a
String
when configuring an extension would be the most use-friendly – then mapping it to
RegularFileProperty
when passed to the actual task. I’ll stick to that approach, thank you Chris!
👍 1
s
You can also accept an Object and use
Project#file
if I understand you correctly. Then the user could choose what to pass you
j
That’s pretty interesting – but I have bad feelings about it, I’m not sure why.
c
it’s a hold-over from the very-loosely-typed Groovy heritage of Gradle; cleanest to provide type-safety where possible.
s
People do still write builds using Groovy 😉
v
Differently put, this was a recommended practice looong ago, but is bad practice now. ;-)