gradle-download-task: download files with progress

I really like how Gradle dis­plays pro­gress while it’s fetch­ing ar­ti­facts from Maven re­pos­it­or­ies, but I was al­ways won­der­ing why you can­not use the same func­tion­al­ity when you’re down­load­ing ar­bit­rary files in your build script. You can of course use An­t’s down­load task to fetch files, but it does not dis­play pro­gress in­form­a­tion. Since I could­n’t find a solu­tion on the In­ter­net I de­cided to write a plug­in.

gradle-down­load-task has ini­tially been re­leased in Septem­ber 2013 and is now avail­able in ver­sion 5.0.0. The plug­in con­trib­utes a down­load task that shows pro­gress in­form­a­tion just like Gradle does when it fetches ar­ti­facts from a re­pos­it­ory.

You can use it like this:

task downloadFile(type: Download) {
    src ''
    dest buildDir

The out­put will look like this:

In or­der to use the plug­in you have to add the fol­low­ing lines to your build file:

plugins {
    id "" version "5.0.0"

You can also use the down­load ex­ten­sion to re­trieve a file any­where in your build script:

apply plugin: 'download-task'

task myTask {
    doLast {
        // do something ...
        // ... then download a file {
            src ''
            dest buildDir
        // ... do something else

You can also down­load a list of files to a dir­ect­ory. Please note that you have to spe­cify a dir­ect­ory as des­tin­a­tion if you down­load mul­tiple files. Oth­er­wise the plug­in will fail. Since gradle-down­load-task 5.0.0 the down­loads will be per­formed in par­al­lel.

task downloadMultipleFiles(type: Download) {
    dest buildDir

The plug­in sup­ports a wide range of other op­tions. Please read the README file for more in­form­a­tion.

Happy down­load­ing!

If you or your com­pany use any of my pro­jects or like what I’m do­ing, please con­sider spon­sor­ing me so I can con­tinue main­tain­ing and de­vel­op­ing my pro­jects and new ones!

Thank you so much for your sup­port!

Posted by Michel Krämer
on March, 22nd 2014.