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 1.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:

> Building > :downloadFile > 320 KB/6.78 MB downloaded

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

buildscript {
    repositories {
    dependencies {
        classpath 'de.undercouch:gradle-download-task:1.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 << {
    //do something ...
    //... then download a file
    download {
        src ''
        dest buildDir
    //... do something else

With ver­sion 1.0 you can now also se­quen­tially 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.

task downloadMultipleFiles(type: Download) {
    dest buildDir

Many thanks go to Bright Fulton who con­trib­uted sup­port for cus­tom HTTP re­quest head­ers. You can use this new fea­ture as fol­lows:

task downloadWithCustomHeader(type: Download) {
    src ''
    dest buildDir
    header 'Cookie', 'oraclelicense=accept-securebackup-cookie'

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!

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