以下gradle任务复制目录,但解析所有符号链接(symbolic link)。这是无法接受的。我想保留。
task test {
doLast {
copy {
from 'source'
to 'destination'
}
}
}
该怎么办?
最佳答案
该“错误”有一个open issue
现在,您可以检测符号链接(symbolic link),也可以手动创建它
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
copy {
from $source
into $destination
eachFile { details ->
Path pathFile = FileSystems.getDefault().getPath(details.file.path)
if(Files.isSymbolicLink(pathFile)) {
details.exclude()
commandLine 'ln', '-s', Files.readSymbolicLink(pathFile), "$destination/${details.relativePath}
}
}
}
关于gradle - 如何在Gradle保存符号链接(symbolic link)中复制目录?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52291761/