The following behaviour was observed under Windows 10 and Gradle 8.14.
Assuming the following situation:
One directory with regular files, like text files.
A Second directory with symbolic links pointing to the files in the first directory.
A third directory with a Gradle project containing a custom task to copy files into the second directory.
tasks.register<Copy>("copyDirectoryContents") {
from("docs")
into("E:\\workspace\\gradle_copy_bug\\target_directory")
}
When performing the task and there is a symbolic link with the same name as a file from the project, instead of overriding the symbolic link with the regular file the content of the file where the symbolic links is pointing to is being replaced.
Before executing task:
|- dir_one
| |- test.txt (with content: "Hello world!")
|- dir_two
| |- test.txt (symbolic link pointing to dir_one/test.txt)
|- dir_three
| |- docs
| |- test.txt (with content: "Hello from Gradle directory!")
After executing task:
|- dir_one
| |- test.txt (with content: "Hello from Gradle directory!")
|- dir_two
| |- test.txt (symbolic link pointing to dir_one/test.txt)
|- dir_three
| |- docs
| |- test.txt (with content: "Hello from Gradle directory!")
Expected behaviour:
|- dir_one
| |- test.txt (with content: "Hello world!")
|- dir_two
| |- test.txt (with content: "Hello from Gradle directory!")
|- dir_three
| |- docs
| |- test.txt (with content: "Hello from Gradle directory!")
Simply deleting the target directory before the task is being called is unfortunately not an option, as there are other files in there that need to be preserved.
Is my expectation of that behaviour wrong or is there a possibility to configure the copy task to perform in the expected way?