Automatic clean tasks for a copy task deletes the entire directory files were copied to rather than just the output files of the task

It seems that the automatic clean tasks provided by gradle have a bug. If I have a copy task that copies some files to an existing directory and specifys the output of the tasks as follows:

filterRundeckConfig.outputs.files files("…/…/rundeck/rundeck_config/", “…/…/rundeck/rundeck_config/profile”)

gradle cleanFilterRundeckConfig

deletes the directory the files were copied to, not just the files that were copied.

This seems to be a known issue, see