I have a simple copy task:
task copyWebToBin(type: Copy, dependsOn: jar) {
into myBinDir
from sourceSets.main.resources
include 'web/**'
}
The problem is that the target ‘myBinDir’ is a VERY large directory structure (with thousands of files in sub-directories), and the UP-TO-DATE check takes some time to produce the snapshot.
Is there any way to limit the content of that snapshot operation?
I tried the following approach:
task copyWebToBin(type: Copy, dependsOn: jar) {
includeEmptyDirs = false
into "$myBinDir/web"
from sourceSets.main.resources.getSourceDirectories().asFileTree.matching {
include 'web/**'
}
eachFile { FileCopyDetails fcp ->
fcp.relativePath = new RelativePath(!fcp.isDirectory(), (String[]) fcp.relativePath.segments[1..-1].toArray())
}
}
And, the UP-TO-DATE check now runs in .001 seconds, but all of that was pretty cumbersome (and I do copy operations like this in a lot of places in the build). So, I was wondering if there’s an easier or less verbose way to accomplish the same thing.