Not sure if this is exactly what you are trying to do, but have a look at this simple example in the cookbook. http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-ExampleofasimplecustomtaskwithinbuildSrc
Philip On Wed, Dec 9, 2009 at 4:03 PM, Adam Murdoch <[email protected]> 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 > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
