英文:
Zip directory to multiple destinations using Gradle
问题
能否使用Gradle的Zip任务将结果zip复制到多个目标位置?
据我所知,您只能使用一个输出目标将多个输入目录压缩成一个zip。有没有一种方法可以将目录压缩并将存档复制到多个目标位置(在一个单独的任务中)?由于我必须使用Gradle v5.0,非常希望能够为该版本的Gradle找到解决方案。
英文:
Is it possible with Gradle's Zip task to copy the resulting zip into multiple destinations?
AFAIK you can only zip multiple input directories with only one output destination. Is there a way to zip a directory and copy the archive to multiple destinations (in one single task)? Since I'm bound to using Gradle v5.0, a solution for that version of Gradle would be highly appreciated.
答案1
得分: 1
Zip
任务的内部操作只会将zip文件输出到单个目录。如果你不想创建额外的Copy
任务,你可以使用一个doLast
闭包,并使用Project
实例提供的copy
方法。
task myZip(type: Zip) {
...
doLast {
copy {
from archivePath
into 'path/to/other/destination'
}
}
}
英文:
The internal action of Zip
tasks will only output the zip file to a single directory. If you don't want create additional Copy
tasks, you may use a doLast
closure and use the method copy
provided by the Project
instance.
task myZip(type: Zip) {
...
doLast {
copy {
from archivePath
into 'path/to/other/destination'
}
}
}
答案2
得分: 0
我建议您使用一个复制任务来进行复制操作,并可能在Zip任务上添加一个‘finalizedBy’语句。
有关将内容复制到多个目标的信息可以在这里找到。
英文:
I suggest you use a Copy task for the copying, and possibly add a 'finalizedBy' statement on the Zip task.
Copying into multiple destinations is covered here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论