You could remove the dangling symlinks using an exec task first http://www.commandlinefu.com/commands/view/2369/find-broken-symlinks-and-delete-them
task removeDanglingSymlinks(type:Exec) {
commandLine 'find', '-L', file("${buildDir}").absolutePath, '-type', 'l', '-delete'
}
if (!System.properties['os.name'].toLowerCase().contains('windows')) {
someOtherTask.dependsOn removeDanglingSymlinks
}