@Luke it is necessary to coerce the segments back into a String Array after removing elements. The code below works but has the unintended side effect of also copying the original directory structure with no files in it. Any thoughts?
eachFile { FileCopyDetails fcp ->
if (fcp.relativePath.pathString.startsWith(appName)) {
// remap the file to the root
def segments = fcp.relativePath.segments
def pathsegments =segments[1..-1] as String[]
fcp.relativePath = new RelativePath(!fcp.file.isDirectory(), pathsegments)
}
else {
fcp.exclude()
}
}