I might be getting something wrong, but it seems that automatic clean of a copy task doesn’t do the right thing.
The problem is that if the “contents” directory in the example below already contained something before the copySomeStuff task is executed it will be deleted when the cleanCopySomeStuff is called. If one prints the outputs of the copy task it contains the directory instead of list of actually copied files.
task(copySomeStuff, type: Copy) {
from configurations.runtime
into "some/already/existing/destination/with/some/contents"
doLast{
outputs.files.each {
println it
}
}
}
What makes it worse is that it does not even seem possible to override the outputs of the copy task with the files being copied. In my case, even with something like