gpt4 book ai didi

gradle - 如何在gradle zip任务中排除路径信息

转载 作者:行者123 更新时间:2023-12-03 05:10:48 25 4
gpt4 key购买 nike

对于这个简单的问题,我事先表示歉意。

我想在构建过程中运行Zip任务,并在我的“归档”目录中创建一个.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}")
}

最佳答案

解决方案比我想象的要简单得多。下面将扁平化结构

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}")
}

关于gradle - 如何在gradle zip任务中排除路径信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47682093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com