Adding additional properties to tasks
A task
object already has several properties and methods. But we can add any arbitrary new property to a task and use it. In the following sample, we print the value of the task property message. The value of the property is assigned with the statement simple.message = 'world'
:
task simple << { println "Hello ${message}" } simple.message = 'world'
When we run the task we get the following output:
$ gradle -q simple Hello world