Hi,

I'd like to get some feedback on the new task definition DSL I've added to trunk.

The changes replace the createTask() method with a keyword style syntax for use in build scripts, and a groovy-ish API for use elsewhere.

The new syntax is:

task <task-name> [(option...)] [ { action } ]

Some examples:

task aTask  // was createTask('aTask')

task aTask { do stuff } // was createTask('aTask') { do stuff }

task aTask(type: Copy, dependsOn: someOtherTask) // was createTask('aTask', type: Copy, dependsOn: someOtherTask)

task aTask(dependsOn: anotherTask) { do stuff } // you can figure this one out

More examples in the user guide at http://gradle.org/userguide/latest/tutorial_using_tasks.html

One thing to note is that this syntax works only for statements. It does not work for expressions. That is, you can't do:

Task someVar = task aTask

For one thing, this isn't actually valid groovy. It would have to look like:

Task someVar = task(aTask)

which defeats the purpose, I think. It also looks a lot like a call to the Project.task() method, which is confusing, I think:

Task someVar = task('anExistingTask')

or worse:

taskName = 'anExistingTask'
Task someVar = task(taskName) { configure the task }

For both these reasons, I've limited the syntax to statements.

For defining a task in an expression, or in classes outside the build script, you can use the API on TaskContainer:

tasks.add(name: 'aTask') // replaces createTask('aTask')
tasks.add(name: 'aTask') { do something }
tasks.add(name: 'aTask', type: Copy)

Finally, Project.createTask() will be deprecated in the 0.6 release, and removed some time after the release.

Comments?


Adam


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

   http://xircles.codehaus.org/manage_email


Reply via email to