RegularFileProperty and user flexibility

plugins

(Andreas Axelsson) #1

In the past I used to have Object properties on my tasks and lazily convert them to whatever I needed, including via closures. This make it easy for the user to assign whatever is needed.

task foo(MyTask) {
   fileA 'bar'
   fileB = project.file('bar')
   FileC { 'bar' }
   FileD = 'bar'
}

With the Property<> system, it’s very tempting to go for the typed properties, but it then requires users to assign only the right type, which I feel reduces usability, and Property<Object> feels a bit wrong.

task foo(MyTask) {
   fileA project.file('bar')
   fileB = project.file('bar')
   FileC = { project.file('bar') }
   FileD = project.file('bar')
}

Do you have any advice on which approach I should take? Are there plans on making these properties more accepting to types that can be converted later? Property<String> can’t even take a GString now, for instance.