0.6 Task definitions in plugins

View: New views
2 Messages — Rating Filter:   Alert me  

0.6 Task definitions in plugins

by JerodLass :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

With the new task declaration scheme, it looks like I'm going to need to make a lot of changes to the plugins I am using.  Since createTask() is a deprecated method of Project, how will I go about creating tasks in my plugin classes?

Currently, I am declaring as follows:

project.createTask('buildTag', dependsOn: 'resources') {
    //task logic
}

How will I achieve the same in Gradle 0.6?

Thanks,
Jerod

Re: 0.6 Task definitions in plugins

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



JerodLass wrote:

> With the new task declaration scheme, it looks like I'm going to need to make
> a lot of changes to the plugins I am using.  Since createTask() is a
> deprecated method of Project, how will I go about creating tasks in my
> plugin classes?
>
> Currently, I am declaring as follows:
>
> project.createTask('buildTag', dependsOn: 'resources') {
>     //task logic
> }
>
> How will I achieve the same in Gradle 0.6?
>
>  

You have a couple of options.

You can use the API which the build script DSL uses, which is to use the
add() method on TaskContainer:

project.tasks.add(name: 'buildTag', dependsOn: 'resources') << {
    // task logic
}

There's a couple more examples in the userguide at
http://www.gradle.org/0.6.1/docs/userguide/more_about_tasks.html#N109B2

Have a look at the Javadoc for TaskContainer at
http://gradle.org/0.6.1/docs/javadoc/org/gradle/api/tasks/TaskContainer.html

Another option, which isn't officially part of the public API (but
possibly should be) is to use the task() method on Project:

project.task('buildTag', dependsOn: 'resources') << {
    // task logic
}

This is much closer in syntax to createTask(), except you should note
that the closure passed to it is used to configure the task, not treated
as its action.


Adam


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

    http://xircles.codehaus.org/manage_email