Sorry, I missed a comma in the no parenthesis examples (edited above).
In the case of a type
, you need the comma before the closure. The comma would be optional for some of the other named arguments with different argument types, like dependsOn: 'otherTask'
. It just depends on if the syntax is unambiguous to Groovy.
Regardless, just because you can call the task
function many different ways, there’s not really a good reason to do so. The convention for an eager task is to write it as (but it’s still the same method call as the other ways):
task hello(type: Copy) {