Copy w/DuplicatesStrategy.EXCLUDE overwrites files

Hi there

I’ve apparently found a potentially serious problem in the copy task, Gradle v. 1.12.

When copying files with the duplicatesStrategy= DuplicatesStrategy.EXCLUDE, it will overwrite files with different case on file systems with case insentitive file names.

e.g. (pseudo-code-ish…)

task copySomeFiles(type: Copy) {
    duplicatesStrategy= DuplicatesStrategy.EXCLUDE
    from 'somePath/readme.txt'
    from 'anotherpath/README.TXT'
    into destination
}

will result in destination/readme.txt having the content of README.TXT.

Kind regards, Povl

}

so what should Gradle do? If you want to have these files residing in different folders, you have to tell it explicitely.

I am aware that this may not be a trivial problem, but DuplicatesStrategy.EXCLUDE clearly states that files should not be overwritten. This appears not to be the case.

I don’t know how Gradle determines if two file names are the same, but a simple string compare is not enough to determine if two file names will end up being the same file in the file system. It depends on how the file system handles upper/lowercase characters.

See java.io.File.equals:

public boolean equals(Object obj)

Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is an abstract pathname that denotes the same file or directory as this abstract pathname. Whether or not two abstract pathnames are equal depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.

I hit the same bug on Windows; setting caseSensitive = false does not help. Thing to note is that I am running java via Cygwin; not sure if that makes any difference in how files are compared or not…