Up-To-Date for empty inputs

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
        }
    }
}