Maybe the first way you find is to use Gradle’s append syntax to define the task.
But if you try to define task inputs and outputs with the above task type, Gradle will warn you in the console that up-to-date checking wasn’t supported in this task.
Don’t despair, there is a solution! You can use a doLast closure inside the Gradle task to be able to copy multiple directories and still use up-to-date checking. This is what the resulting task might look like with up-to-date checking enabled:
Now you have a single task that will copy multiple directories and will only run when one of those defined inputs or outputs changes!