The Copy api doesn't mention a flag/property that can be set. So what's the default action and how can one modify it?
According to this,
As of Gradle 0.9.1, the Copy task always overwrites files. The other strategies are not supported yet.
As the issue text says, the Copy
task overwrites files, and other strategies aren't currently supported. If that's not appropriate in your case, you can always fall back to the Ant task.
Check out DuplicatesStrategy http://www.gradle.org/docs/1.7-rc-1/release-notes#duplicate-file-handling-for-copy-and-archive-operations and http://www.gradle.org/docs/current/javadoc/org/gradle/api/file/DuplicatesStrategy.html. Both should work for non-overwrite copying (while overwrite-copying is default).
duplicatesStrategy 'exclude'
Also check out Gradle Zip DuplicatesStrategy not working correctly for a possible bug that exists with nested "from"s.
I have the same problem when i use the Task Copy, gradle always performs up-to-date check which causes copying be skipped.
After read more on the gradle user manual, i find out that we can use project.copy() method instead of the task Copy. This method skip the up-to-date check, thus files will be always be copyed to destination.
task myCopy << {
copy {
from (yourSourceDir)
into (yourDestDir)
}
}