Got it. The first thing that correct TaskAction class must be imported. The
second thing is that writing in groovy with IDEA says there must be much
more method names implemented (that`s why I gone wrong way initially). I
tried to rewrite it as java class file but it still requires invokeMethod()
to be implemented and some others. Also java class is unhandy couse groovy
objects are unavailable.
Finally I tried to configure gradle sources as dependency instead of
gradle-core jar and IDEA is parsing my sources with no errors. Thank You!
Adam Murdoch-2 wrote:
>
>
>
> On 10/12/09 7:12 AM, Narco wrote:
>> Hello!
>>
>> I know I`m not good in Java but all I want for now is to create Class
>> which
>> will work as task instead of:
>> project.getTasks().add("myTask")
>> project.myTask<< {
>> ...
>> }
>> I want:
>> MyTask myTask = project.getTasks().add("myTask", MyTask.class);
>> myTask.dependsOn(...)
>>
>> I`m trying to accomplish that like this:
>> public class MyTask extends AbstractTask{
>> void execute(){
>> ...
>> }
>> }
>>
>> The problem is with methods I need to implement like doFirst. I tried to
>> write it like this:
>> Task doFirst(Closure action) {
>> if (action == null) {
>> throw new InvalidUserDataException("Action must not be
>> null!");
>> }
>> actions.add(0, convertClosureToAction(action));
>> return this;
>> }
>>
>> The build is running but this is ignored after then:
>> myTask.doFirst {
>> println "working???"
>> }
>>
>> What am I doing wrong? Please help!
>>
>>
>
> You shouldn't really be extending AbstractTask. DefaultTask is the
> public class to base your custom tasks on.
>
> Have a look at http://gradle.org/0.8/docs/userguide/custom_tasks.html
>
>
> --
> Adam Murdoch
> Gradle Developer
> http://www.gradle.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
--
View this message in context:
http://old.nabble.com/How-to-write-custom-Task-class-tp26716825p26724450.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email