Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to return from task and mark task as being 'up-to-date'

Tags:

gradle

I would like to programmatically tell gradle to return from a task, for example:

task ('SetupLibs') << {

    if (sometest)
       // how to tell gradle to return from this task 
       // because it is up-to-date 

    ...
}

Is this possible in groovy? how?

like image 367
Chris Snow Avatar asked Mar 21 '16 13:03

Chris Snow


2 Answers

You can use upToDateWhen(){...}

for example:

task foo() << {
  outputs.upToDateWhen {
    if (sometest) return true
  }
}
like image 149
RaGe Avatar answered Nov 05 '22 07:11

RaGe


You might want to consider simply skipping the task, assuming you truly don't want it to do anything https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:skipping_tasks

like image 2
awesomeamyg Avatar answered Nov 05 '22 05:11

awesomeamyg