为这个简单的问题提前道歉我对Gradle来说相对较新。
我想在构建过程中运行Zip
任务,并在我的“archive”目录中创建一个.zip
文件,但没有源文件的目录结构。我设法使task
正常工作,但保留了目录结构。我读到对于linux Zip,有一个选项-j或-r,它会使目录变平,但我不确定这是否可以通过Gradle任务使用。
My input file structures looks similar to the below,
./libs/
./libs/file1.jar
./scripts/script1.sh
./scripts/script2.sh
但我希望最终得到一个包含目录结构的Zip文件,如下所示,
./
./file1.jar
./script1.sh
./script2.sh
我当前的Zip任务如下,
task makeZipForDeploy(type: Zip) {
from 'build/'
include 'libs/*' //to include all files in libs folder
include 'scripts/*' //to include all files in the scripts folder
archiveName("${archiveFileName}")
destinationDir file("${archivePath}")
}
答案 0 :(得分:1)
task makeZipForDeploy(type: Zip) { from 'build/libs' //to include all files in libs folder from 'build/scripts' //to include all files in the scripts folder archiveName("${archiveFileName}") destinationDir file("${archivePath}") }