i have this gradle task to get zip content and put it into another zip.
From src zip, i want to take all in directory 'r' and copy it into the target zip directory 'x/y/z'.
The code works, but I wonder if it can be more elegant.
from( zipTree("a.zip") ) {
include "r/**"
includeEmptyDirs = false
into "x/y/z"
eachFile { fcd ->
def segs1 = [fcd.relativePath.segments].flatten().findAll { it2 -> it2 != null };
segs1.removeAt(3)
fcd.relativePath = new RelativePath(true, segs1.toArray(new String[0]))
}
}
The problem I had is that fcd.relativePath.segments is String[], where i want to remove element with index 3.
Here i convert to list and back to array, brrr.
Ideas?
Frank