Download files with progress information: first release of the gradle-download-task plugin available!

If downloading of one file fails, script exits execution. Any idea, how to continue with the remaining files?

you can always run gradle with --continue to proceed with the build and run as much tasks as possible

Can you provide an example where this actually happens, so I can reproduce?

Cheers, Michel

I just added the example to the readme. Looks pretty simple.

Cheers, Michel

That example throws error 401(Authorization Required Error) for my URL. Even though I have provided Username and Password.

Did you check you username and password? When does the error occur? When the plugin is trying to download the first URL or the second?

Error occurs at “def files = urlLister.listFiles(new URL(dir))”. Username and password is correct. If I specify individual file path, then it works perfectly. Do we have to enable “Directory Listing” for that website?

ApacheURLLister is a class from Ivy and not from gradle-download-task. I don’t know how authentication works there. Please consult Ivy’s documentation.

And yes, you have to enable Directory Listing. Otherwise the ApacheURLLister won’t work at all.

Cheers, Michel

Thanks Micheal. Will enable it. :slight_smile:

I have enabled it. Still facing the same error. I guess, I need to specify the credentials for IVY as well. I am using Gradle and how/where can I specify credentials for IVY?

As I said: “I don’t know how authentication works there. Please consult Ivy’s documentation.” Thanks for your understanding.

Michel

Thanks Michel :slight_smile:

Hi, I am getting the following exception

  • What went wrong: A problem occurred evaluating script. > Failed to apply plugin [id ‘download-task’]

Plugin with id ‘download-task’ not found.

I have the following configuration buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath ‘de.undercouch:gradle-download-task:1.0’

} }

import de.undercouch.gradle.tasks.download.Download

apply plugin: ‘download-task’

Regards,

Carlos

Hi carledriss,

I can’t reproduce this. What Gradle version are you using? Have you tried the example? https://github.com/michel-kraemer/gradle-download-task/blob/master/example/build.gradle

Cheers, Michel

Hi Michel,

The problem was that I defined the task in a file different than build.gradle for example download.gradle and the build.gradle only was applying from: ‘download.gradle’

I defined the buildscript, and apply plugin: ‘download-task’ in the build.gralde and It is working.

Cool. Thanks for the feedback!

Cheers, Michel

Hi Michel,

It was a nice move. Thanks!!

I need the assistance, my scenario is like this, I am downloading a file/image from URL and wants to download into the project resource folder.(ANDROID APPLICATION). I am using Android Studio and Gradle. This is my code:

import de.undercouch.gradle.tasks.download.Download

task downloadFile(type: Download) {

src ‘http://central.maven.org/maven2/de/undercouch/gradle-download-task/1.0/

dest ‘/ExternalRes/’ }

The Gradle is executing successfully but I can’t able to see file into the file directory i.e “ExternalRes”

Dear Amarpeet,

Your code looks OK. Note that ‘/ExternalRes/’ is an absolute path. Please check if that’s what you want. If you want a relative path, remove the slash ‘/’ at the beginning of the string. The file will then be downloaded to your project folder.

Cheers, Michel

I would need to authenticate with username and password to download the file from URL. Please suggest me how to do it.

Just have a look at the README: https://github.com/michel-kraemer/gradle-download-task

The download task supports a ‘username’ and ‘password’ option.

Hope this helps. Let me know if you need further assistance.

Cheers, Michel