I think I understand now what you want your build to do:
skip the generate
tasks when the output file of the generate
task already exists.
I am not yet sure if you need the output of the download
task as well, even when you have the output of the generate
task. My suspicion is that you don’t, so you may want to skip it as well when the output of the generate
task is present.
Gradle has a way to skip tasks (i.e. don’t execute them depending on a condition): Task.onlyIf()
. See the user manual for more information.
In your case, you can add the onlyIf
condition to the generate
and download
tasks:
download.onlyIf { !layout.buildDirectory.file(name).exists() }
generate.onlyIf { !layout.buildDirectory.file(name).exists() }
Cheers,
Stefan