External Dependencies download time

I our project, we use an external dependency required for a task. So far, it si automatically downloaded at configuration time and we would have preferred it to be downloaded at build time only.

configurations {

dependencies {
ext (
group: “x.y.depend”,
name: “ext”,
version: “${project.extVersion}”,
classifier: “bin”,
ext: “zip”

task extractFile(type: Copy) {
copy {
from ({zipTree(configurations.ext.singleFile)})
into “${buildDir}/ext”
include “**/*.tar”

I tried doing the extraction inside a doLast to hide it and this can work but then the incremental build does not see when the dependency changes. I need to declare an input (zip file) and output (directory) so that the dependency is downloaded again when it changed.

Does anyone have an idea how I can achieve my goal?