gradle, gretty - How to run a task in farm task?

669 Views Asked by At

I would like to run a task in farm task:

farm {
   // run my task here.
}

Can anyone help me with this?

1

There are 1 best solutions below

4
On BEST ANSWER

farm is an extension - not a task - so it cannot be run. Also mind the fact that it's not good idea, nor good practice to run task programmatically. You need to define your own task and then define a dependency:

task myTask << {
   println "Here's an action"
}

farmRun.dependsOn myTask

or:

task myTask << {
   println "Here's an action"
}

project.afterEvaluate {
   farmRun.dependsOn myTask
}

Please have a look at the demo here.