What would be the proper gradle way of downloading and unzipping the file from url (http
)?
If possible, I'd like to prevent re-downloading each time I run the task (in ant.get
can be achieved by skipexisting: 'true'
).
My current solution would be:
task foo {
ant.get(src: 'http://.../file.zip', dest: 'somedir', skipexisting: 'true')
ant.unzip(src: 'somedir' + '/file.zip', dest: 'unpackdir')
}
still, I'd expect ant-free solution. Any chance to achieve that?
@CMPS:
So lets say you want to download this zip file as a dependency:
You define your ivy repo as:
and then use it as:
Borrowing @Matthias' unzip task, except picking up the zip from gradle cache:
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 orCopy
task).Unzipping using the copy task works like this:
http://mrhaki.blogspot.de/2012/06/gradle-goodness-unpacking-archive.html