Don't follow Smylinks on a delete using ant internally

Hi, I’m hitting the dangling and following symlink when I try to purge a workspace via gradle. I tried using project.delete and then switched to ant. I guess, I need to use java.nio to identifiy and unlink first then use project delete.

// Unlink
        directoryToPurge.eachFileRecurse { child ->
            if (Files.isSymbolicLink(Paths.get(child.absolutePath))) {
                ant.symlink(link: child.absolutePath, action: ant.symlink.delete) {
                    failonerror=true
                }
            }
        }
   ant.delete() {
                    verbose = true
                    removeNotFollowedSymlinks = false
                    ant.fileset(dir: localWorkingCopy.absolutePath, includes: "**" ) {
                        followsymlinks
= false
                    }
                }

Ok this Seems to work but it seems cumbersome

private void purgeDirectoryChildrenContainingSymlinks(File directoryToPurge) {
                  // Walk and Unlink all Symlinks
        directoryToPurge.eachFileRecurse { child ->
            Path childPath = Paths.get(child.absolutePath)
            if (Files.isSymbolicLink(childPath)) {
                Files.delete(childPath)
            }
        } else {
        // Purge
        project.delete(project.file(child.absolutePath))
        }
    }

This works. Seems a little ugly to me as it must traverse multiple times and it very may well fail on multiple layers of symlinks

private void purgeDirectoryChildrenContainingSymlinks(File directoryToPurge) {
          // Walk and Find all Symlinks
        def pathsToPurge = []
        directoryToPurge.eachFileRecurse { child ->
            Path childPath = Paths.get(child.absolutePath)
            if (Files.isSymbolicLink(childPath)) {
                pathsToPurge << childPath
            }
        }
          // Purge all Symlinks
        pathsToPurge.each { child ->
            Files.deleteIfExists(child)
        }
            // Walk and Purge remaining file structure
        directoryToPurge.eachFile { child ->
            project.delete(project.file(child.absolutePath))
        }
    }