我想创建多个gzip文件为每个txt文件在一个FileTree。这是我的gradle任务:
task gzipFiles << {
FileTree tree = fileTree('build/dist') {
include '**/*.txt'
}
tree.each {File file ->
println file
String fileName = file.getName()
//create gzip file
}
}有没有在FileTree each循环中使用Tar任务来创建gzip的方法呢?
发布于 2016-08-08 15:27:28
不,这是不可能的--那样是行不通的。你能做的就是反转处理,这就是你要做的:
task all
fileTree('input') {
include('**/*.txt')
}.each { f ->
task "tar_$f.name"(type: Tar) { t ->
from f.parentFile
include f.name
baseName = "$f.name"
destinationDir = project.file('output')
all.dependsOn(t)
}
}Here是演示。
https://stackoverflow.com/questions/38802186
复制相似问题