TrevJonez
05/29/2024, 2:41 PMup-to-date
or skipped
from within the main @TaskAction
function?
use-case: task that will use an exec of git to grab time information about a file then make 2 or 3 api calls to determine the state of the file on a 3rd party remote to decide if it should do the actual task action of uploading for processing. I've got dozens of this task type in a single invocation and I want to be able to filter my buildscan timeline/logging quick and easy.TrevJonez
05/29/2024, 2:43 PMTrevJonez
05/29/2024, 2:45 PMVampire
05/29/2024, 2:51 PMonlyIf
is execution time and I/O should thus be fine.
Within a task action you cannot mark a task as up-to-date or skipped, because it is already running, so it can neither be up-to-date nor skipped, because it is already running.
But you can just return from the task action, not doing the work if onlyIf
for example is not an option.Thomas Broyer
05/29/2024, 4:21 PMdidWork
from the task action though: https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:didWork
(no idea how it will reflect in the task status, possibly up-to-date)TrevJonez
05/29/2024, 4:29 PMdidWork = false
seems to mark it as up to date so long as there was no other action after you set it to false.
IE: this will produce an UP-TO-DATE
tasks.register("behaviorCheck") {
doFirst {
println("doing first")
didWork = false
}
}
where as this will produce a SUCCESS
tasks.register("behaviorCheck") {
doFirst {
println("doing first")
didWork = false
}
doLast {
println("doing last")
}
}
TrevJonez
05/29/2024, 4:29 PMTrevJonez
05/29/2024, 4:29 PM