New features in gradle-download-task 3.4.0
source link: https://michelkraemer.com/gradle-download-task-3.4.0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
New features in gradle-download-task 3.4.0
The new version 3.4.0 of gradle-download-task, a Gradle plugin providing a Download
task that display progress information, has just been released. It contains many new features and updating is recommended for all users.
Grab gradle-download-task 3.4.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 4.6 but should be compatible to any other version as well.
New features
Here’s a short overview of all new features (more details below):
- Add support for ETags
- Add
tempAndMove
configuration flag - Register top-level properties
Download
andVerify
for the tasks provided by the plugin - Add
verifyChecksum
extension as an alternative to theVerify
task - Deprecate Java 6
- Deprecate Gradle 1.x
- Add integrations tests for all Gradle versions up to 4.6
Support for the HTTP ETag header
The plugin can now use the HTTP ETag
header to check if a file has been changed on the server or not. You can enable this feature through the onlyIfModified
flag and the new useETag
flag. If both of them are true
, the plugin will check a file’s timestamp as well as its entity tag (ETag) and only download it if it has been modified on the server since the last download. The plugin can differentiate between strong and weak ETags.
Possible values for the new useETag
flag are:
Here’s an example demonstrating how the new flag can be used:
task downloadFile(type: Download) {
src 'https://repo.maven.apache.org/maven2/org/citationstyles/styles/1.0/styles-1.0.jar'
dest buildDir
overwrite true
onlyIfNewer true
useETag true
}
Download to temporary file and move afterwards
One of the most requested features was the possibility to download a file to a temporary location and, upon successful execution, move it to the final destination. This behavior can now be enabled with the new tempAndMove
flag.
If the overwrite
flag is set to false
, tempAndMove
can be used to avoid partially downloaded files if Gradle is forcefully closed or the system crashes. Note that the plugin always deletes partial downloads on connection errors, regardless of the value of this flag.
The temporary location can be configured through the new downloadTaskDir
configuration property. The plugin appends the extension .part
to all temporary files.
The following snippet shows how the new flag can be used:
task downloadFile(type: Download) {
src 'https://repo.maven.apache.org/maven2/org/citationstyles/styles/1.0/styles-1.0.jar'
dest buildDir
tempAndMove true
}
Avoid unnecessary import statement
In previous versions, it was necessary to import the class de.undercouch.gradle.tasks.download.Download
to use the Download
task. With the new version 3.4.0 this import statement is not needed anymore. The same applies to the Verify
task.
Of course, the change is backward compatible. You do not have to modify existing build scripts.
plugins {
id 'de.undercouch.download' version '3.4.0'
}
// NOT NECESSARY ANYMORE
// import de.undercouch.gradle.tasks.download.Download
task downloadFile(type: Download) {
src 'https://repo.maven.apache.org/maven2/org/citationstyles/styles/1.0/styles-1.0.jar'
dest buildDir
}
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 strongly advice to read my blog post on 10 recipes for gradle-download-task to get an idea what you can do with the plugin.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK