Gradle always does println from any task

If You have the following piece of code:

task task1 {
    println 'task1 starting'
}

You’re in configuration phase of a task. This phase is run during script evaluation. If You’d like to print something while task is executed You need to add an action for task.

It looks like:

task task1 << {
   println 'task1 action'
}

This piece of code will be evaluated while the task is being run. << is exactly the same as invoking doLast method on Task’s object. You can add many actions.

EDIT
I also highly encourage you to read this blog post.

Leave a Comment