As i said "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!" where I meant that IDEA is now working correctly and DefaultTask
doesn`t require to inherit any methods anymore. Now I feel much stronger on
Gradle and already started huge redesign of classes. Thank You one more
time!
Adam Murdoch-2 wrote:
>
>
>
> On 10/12/09 8:45 PM, Narco wrote:
>> Got it. The first thing that correct TaskAction class must be imported.
>
> I've removed the duplicate TaskAction in trunk, so now there's only 1
> class called TaskAction.
>
>> 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).
>
> This is a bug in intellij 8, where it complains that a bunch of methods
> inherited from GroovyObject are not implemented. You can ignore these -
> it will compile fine. If you extend DefaultTask, you don't need to
> implement any inherited methods at all.
>
>> 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
>>>
>>>
>>>
>>>
>>>
>>
>
> --
> 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-tp26716825p26739876.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