Retry download task if the destination file is missing

Under some circumstances, Gradle seems to decide that the destination
file being absent is the download task's expected outcome.  It caches
this state, and refuses to retry the download in the future since it
thinks the task is up-to-date.  We can correct this by telling Gradle
that the task should not be considered up-to-date if the file is
missing, as recommended by
<https://discuss.gradle.org/t/task-up-to-date-but-outputfile-not-created/17568/2>.
This commit is contained in:
Ben Liblit 2018-07-19 21:33:44 -05:00 committed by Manu Sridharan
parent 0510c914bb
commit 10d3adf324
1 changed files with 6 additions and 0 deletions

View File

@ -28,6 +28,12 @@ class VerifiedDownload extends org.gradle.api.DefaultTask {
return project.file(dest)
}
VerifiedDownload() {
outputs.upToDateWhen {
getDest().exists()
}
}
@TaskAction
downloadAndVerify() {
def destFile = getDest()