Problem calling a (Tar) task as a method

I want to build a few different tar balls out of several customized-built folders. It would be very convenient to be able to call a tar method like the “copy” method. I read from the DSL

The tasks of the project. A method is added for each task, using the name of the task as the method name and taking a single closure or Action parameter. The method calls the Task.configure() method for the associated task with the provided closure. For example, if the project has a task called compile, then a method is added with the following signature: void compile(Closure configureClosure).

So I tried to add code like this

task buildDistribution<<{
 ....
  Tar{
    from ...
    ....
  }
}

I got the following error message

with an exception.
                 * Where:
       Build file 'C:\deploy\biz_sim\build.gradle' line: 255
                 * What went wrong:
Execution failed for task ':buildDistribution'.
> Could not find method Tar() for arguments [build_4fgqebiufm7j6662h3rmh5n4ft$_run_closure9_closure28@3016eeb9] on root project 'BizSim'.

I tried to add one of my tar task as a method,

task buildTar(type:Tar){
 from ....
 ...
}
task buildDistribution<<{
...
buildTar{}
}

It runs without error, but does everything except building the tar ball. The task DOES build a tar ball when I call it directly with “gralde buildTar”.

I am very confused here. Please help! }

task buildTar(type:Tar) {

from …

… } task buildDistribution<< {

… } buildTar.dependsOn buildDistribution

Now gradle buildTar will call buildDistribution first.

lance,

Thanks. This is fine. But I would like to do several Tar type tasks within buildDistribution (after some copying done). It would be nice to have them as a set of the calls in the end of the buildDistribution task.