gradle-download-task 2.0.0

The new version of the Gradle plugin gradle-download-task 2.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 2.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.6 but should be compatible to any other version as well.

New features

Sematic versioning

The plugin follows the rules of semantic versioning from now on. This means that any new major version introduces (possible) API incompatible changes. Every minor version adds functionality and every patch version fixes bugs. See the homepage of semantic versioning for more details.

Lazy source and destination properties

The src and dest properties of the Download task are lazily evaluated now. This means you can provide closures that will only be evaluated when the task is executed:

task downloadFile(type: Download) {
    src { "${baseUrl}/${version}" }
    dest { "${baseDest}/${version}" }
}

Ignore invalid or self-signed certificates

The Download task supports a new property that can be set to ignore invalid (or self-signed) certificates.

acceptAnyCertificate

true if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted. (default: false)

Destination relative to project

The dest property of the Download task is now relative to the project directory. This is a possible breaking change so I decided to increase the major version number. (Previously the property was relative to the current working directory.)

New Verify task

The plugin provides a new Verify task that can be used to check the integrity of a downloaded file by calculating its checksum and comparing it to a pre-defined value. The task succeeds if the file’s checksum equals the given value and fails if it doesn’t.

Use the task as follows:

import de.undercouch.gradle.tasks.download.Verify
 
task verifyFile(type: Verify) {
    src new File(buildDir, 'file.ext')
    algorithm 'MD5'
    checksum 'ce114e4501d2f4e2dcea3e17b546f339'
}

You can combine the download task and the verify task as follows:

import de.undercouch.gradle.tasks.download.Download
import de.undercouch.gradle.tasks.download.Verify
 
task downloadFile(type: Download) {
    src 'http://www.example.com/index.html'
    dest buildDir
}
 
task verifyFile(type: Verify, dependsOn: downloadFile) {
    src new File(buildDir, 'index.html')
    algorithm 'MD5'
    checksum '09b9c392dc1f6e914cea287cb6be34b0'
}

The verify task supports the following properties:

src

The file to verify (required)

checksum

The actual checksum to verify against (required)

algorithm

The algorithm to use to compute the checksum. See the list of algorithm names for more information. (default: MD5)

More information

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


Profile image of Michel Krämer

Posted by Michel Krämer
on 19 August 2015


Next post

vertx-lang-typescript 1.0.0

Today, I’m excited to announce the first stable version of vertx-lang-typescript, a library that adds support for TypeScript to Vert.x 3! It allows you to write verticles in TypeScript that are automatically compiled when they are executed.

Previous post

Upgrading to Windows 10 fails with error code 80240020

When I tried to install Windows 10 the other day on my laptop, I got an error message. This blog post summarizes a few solutions I found on the Internet for people who are in the same situation.

Related posts

10 recipes for gradle-download-task

gradle-download-task is a Gradle plugin that allows you to download files during the build process. This post summarizes common patterns and use cases of gradle-download-task and provides useful tips and tricks.

New features in gradle-download-task 3.4.0

Version 3.4.0 of the popular Gradle plugin contains many new features. Highlights are the support for ETags and downloading to a temporary file. The update also contains various other improvements.

New major version 5.0.0 of gradle-download-task

I’ve just released gradle-download-task 5.0.0. The new version now downloads multiple files in parallel, executes concurrently with other build tasks, and offers better support for Kotlin and Gradle 8.