I’m not sure how to do this
I’m copying a set of files from Windows to a Linux mounted share. In the process, I’d like to perform a dos2unix on those files.
My code is like this :
def dos2unixExecutable = path/to/dos2unix.exe
copy {
from sourceSets.main.allSource
into file("$destFolder")
eachFile { fileCopyDetails ->
if(Os.isFamily(Os.FAMILY_WINDOWS)){
//apply dos2unix if from windows
exec{
commandLine dos2unixExecutable,"$destFolder/${fileCopyDetails.relativePath}"
}
}
}
}
This doesn’t work because the fileCopyDetails.relativePath is the path of the destionation file, but it doesn"t exist yet. I don’t want to perform the exec task on the source file because I don’t want to modify the source file.
Of course I could perform the copy of all files, and then perform dos2unix once the copy is over. But I really want to perform the dos2unix “on the fly”, to avoid looping two times over the files.