Import task into a project from file


#1

I have a script file with only one task:

task utilTask{
//…
}

apply from automatically runs this task even if I just want to see list of tasks of a project. Is there way to add task to a project from separate script file?


#2

Found solution: just change task declaration
Replace

task utilTask{

with

task utilTask << {

Though there is another problem: description of the task disappears in this case.


(Shawn Crain) #3

Sounds like with your change you moved the setting of the description into the execution phase of the task. Personally I prefer the doLast syntax over << for custom tasks.

task utilTask {
    // configuration phase
    description = "...description..."
    doLast {
         // execution phase: the work you want done when the task is called
    }
}

Check out the docs on the build lifecycle for more insight.


#4

Looks really better, and description shows properly. Thanks