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.
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.
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}" }
}
The Download
task supports a new property that can be set to ignore invalid (or self-signed) certificates.
true
if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted. (default: false
)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.)
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:
MD5
)If you want to learn more about the plugin have a look at its README file or at my previous post.