On May 15, 2009, at 4:34 PM, John Murph wrote:

I still have one reservation about this new syntax.


On Fri, May 15, 2009 at 2:31 AM, Adam Murdoch <[email protected]> wrote:

So, given this, we ended up with:

task name(options-map) { configure-closure } where options-map and configure-closure are optional.

This addresses the above issues, at the cost of some not-so-common groovy code. Personally, I think this is worth the trade-off.

Note also that the above syntax transforms naturally into the syntax for, say, configurations, so that we could allow in the future:

tasks { name(options-map) { configure-closure } }

or

configuration name(options-map) { configure-closure }


I really like this part. I like the clean syntax, the configure- closure consistency with other stuff, and I really like the tasks {} syntax suggestion. All very nice.





There is already a method to add actions to a task. Why is the "<<" syntax needed? It just seems like more non-obvious magic. Could you not just use:
  task hello.doLast { stuff to do }

Adam please correct me if I'm wrong, but as far as I can tell the syntax above is not easy to implement.

What you can do with current trunk is:

task(hello).doLast
{
   println 'hello'
}

doLast and doFirst is too much detail for creating a simple task with an action (where you don't bother about first or last). So let's say we introduce (and we might actually do) a do method which delegates to doLast. Then you could say:

task(hello).do
{
   println 'hello'
}

The parentheses are required (but no magic).

I personally prefer the:

task hello << {
   println 'hello'
}

It just has less clutter (no parentheses, no dot). We were thinking about using the do keyword instead of <<. But considering that this is a Groovy DSL, we decided to go for <<, as this is similar to how Groovy behaves. And 'do' might become a reserved word in Groovy once they introduce do-while. And we had trouble implementing it.

<snip>

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to