Gradle Copy task issue with duplicate file

Hello Team,

in build.gradle I have following code:

task copyModifiedSources(type:Copy) {
    from ('') {
        rename '', ''
    into 'build/generated/src/main/java/com/client/invoker'

I am trying to copy (renamed to before copy) file into build/generated/src/main/java/com/client/invoker folder which already has file.
I am using a duplicate strategy to override from /invoker folder with

If I renamed the copying file to the file name, not in /invoker folder then it works but does not work with the duplicate file name. The file is not copied successfully.

Could you please help me to figure out what is going wrong?

Gradle -> 6.5.1
Java -> 11

Thank you,

It sounds like you have two tasks copying files to the same destination folder. Don’t do this. Each task should have its own, separate, outputs