毕业 - 从url下载和解压缩文件 [英] gradle - download and unzip file from url
问题描述
从url( http
)下载和解压缩文件的正确的渐变方式是什么?
What would be the proper gradle way of downloading and unzipping the file from url (http
)?
如果可能,我想防止每次运行任务时重新下载(在 ant.get
可以通过 skipexisting来实现:'true '
)。
If possible, I'd like to prevent re-downloading each time I run the task (in ant.get
can be achieved by skipexisting: 'true'
).
我目前的解决方案是:
task foo {
ant.get(src: 'http://.../file.zip', dest: 'somedir', skipexisting: 'true')
ant.unzip(src: 'somedir' + '/file.zip', dest: 'unpackdir')
}
仍然,我会期待ant-free解决方案。任何机会实现?
still, I'd expect ant-free solution. Any chance to achieve that?
推荐答案
目前还没有用于从URL下载的Gradle API。您可以使用Ant,Groovy实现,或者如果您希望从Gradle的依赖关系解析/缓存功能中获益,可以假装它是一个具有自定义工件URL的常春藤存储库。解压缩可以按照通常的Gradle方式(复制
方法或复制
任务)。
There isn't currently a Gradle API for downloading from a URL. You can implement this using Ant, Groovy, or, if you do want to benefit from Gradle's dependency resolution/caching features, by pretending it's an Ivy repository with a custom artifact URL. The unzipping can be done in the usual Gradle way (copy
method or Copy
task).
这篇关于毕业 - 从url下载和解压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!