Hi there,
I have a problem with Gradles Copy-Tasks. I defined a custom task that checks if specific files are in the destination directory after copying. Now if the source directory is empty or not existent, gradle skips the task.
I want the file to run if there are inputs OR if files that should be in the destination directory are required.
Now if the source directory is empty or not existent, gradle skips the task.
A task is marked up-to-date if inputs and outputs are existent and didn’t change from the previous execution. Default behavior.
I want the file to run if there are inputs OR if files that should be in the destination directory are required.
If you want custom behavior, you’d have to implement it yourself. For that you could use the copy
method that hangs off of Project
. Something like this:
task myCopy {
outputs.upToDateWhen {
// your custom handling
}
doLast {
copy {
// define source and target locations
}
}
}
Yes, I implemented the outputs.upToDateWhen behaviour so that it checks if the files are in the destination (added a requires(String) method do declare those).
So the behaviour of the outputs is correct. But it doesn’t get to that point if the inputs are empty.
It would be sufficient if it threw an exception at the execution of the task if the inputs are empty. But I don’t know where to do this.