task downloadFile(type: Download) { src 'https://example.com' dest layout.buildDirectory.file('data.zip') overwrite false // Set to true to always download, even if the file exists } Use code with caution. Advanced Usage Examples

Since version 5.0.0, the plugin supports downloading multiple files concurrently.

Retrieve external datasets or configuration files during a build. Download and unpack ZIP or JAR files. Handle multiple file downloads in parallel. Integrating the Plugin (Gradle Focus)

task downloadMultiple(type: Download) { src(['http://example.com', 'http://example.com']) dest buildDir } Use code with caution.

Combine it with Gradle's native Copy task to extract archives immediately after downloading. Maven Alternatives de.undercouch.download - Gradle - Plugins

This plugin provides a dedicated task for downloading files via HTTP, HTTPS, or FTP. Unlike standard build tools that might require complex scripting to fetch external resources, de.undercouch.download offers a clean, declarative syntax. It is frequently used to:

Use the onlyIfModified flag to only download a file if the server reports a newer version, saving bandwidth.

You can define a specific task to fetch a file and save it to your build directory: