我有一个像这样的文件夹结构的项目
blue/folder1
blue/folder2
red/folder3
red/folder4
并且在Gradle中我想单独设置这些文件夹,以便输出看起来像:
build/
tar/
blue/
folder1.tar.gz
folder2.tar.gz
red/
folder3.tar.gz
folder4.tar.gz
这可能吗?我该怎么做?
答案 0 :(得分:1)
apply plugin: 'base'
['blue', 'red'].each { colour ->
file(colour).listFiles().each { File folder ->
if (folder.directory) {
Task tarTask = tasks.create(name: "tar${colour.capitalize()}${folder.capitalize()}", type: Tar) {
from folder
destinationDir = "${buildDir}/${colour}"
archiveName = "${folder}.tar"
}
assemble.dependOn tarTask
}
}
}