如何从任务返回并将任务标记为“最新”

Chr*_*now 6 gradle

我想以编程方式告诉 gradle 从任务中返回,例如:

task ('SetupLibs') << {

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

    ...
}
Run Code Online (Sandbox Code Playgroud)

这在groovy中可能吗?如何?

RaG*_*aGe 4

您可以使用upToDateWhen(){...}

例如:

task foo() << {
  outputs.upToDateWhen {
    if (sometest) return true
  }
}
Run Code Online (Sandbox Code Playgroud)