gradle-download-task 3.0.0

The new version of the Gradle plugin gradle-download-task 3.0.0 has just been released. The plugin provides a Download task that displays progress information while downloading files, just like Gradle does when it fetches an artifact from a repository.

Grab gradle-download-task 3.0.0 while it’s still hot:
https://github.com/michel-kraemer/gradle-download-task

The new version has been tested with Gradle 1.x up to 2.13 but should be compatible to any other version as well.

New features

In the new version the plugin’s core has been rewritten completely. gradle-download-task now uses Apache HttpClient instead of Java’s URLConnection. This enables a whole range of new features including support for authenticating proxies.

Proxy configuration

The new version allows you to configure a proxy server by setting standard JVM system properties. The plugin uses the same system properties as Gradle. You can set them in the build script directly. For example, the proxy host can be set as follows:

System.setProperty("http.proxyHost", "www.somehost.org");

Alternatively, you can set the properties in a gradle.properties file like this:

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

Put this file in your project’s root directory or in your Gradle home directory.

HTTPS is also supported:

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=userid
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

Automatically create target directory

gradle-download-task 3.0.0 automatically creates the target directory if multiple sources are set. For example, given the following task:

task downloadFile(type: Download) {
    src([
        'http://www.example.com/index.html',
        'http://www.example.com/test.html'
    ])
    dest "myTargetDirectory"
}

The target directory myTargetDirectory will be created automatically if it does not exist yet.

More information

If you want to learn more about the plugin have a look at its README file or at my earlier post.

I also stronly advice to read my blog post on 10 recipes for gradle-download-task to get an idea what you can do with the plugin.