1

When I run the below build.gradle.kts script, invoking target downloadAndUnzipFile for the first time, when I run with clean build directory, I get an error.

> Task :downloadZipFile
Download https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip

[...]

Execution failed for task ':downloadAndUnzipFile'.
> Cannot expand ZIP '/home/jdanek/repos/testing/gradle-infer-deps/build/downloads' as it is not a file.

If I rerun the same task immediately, I get success now

> Task :downloadZipFile
Download https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip

> Task :downloadAndUnzipFile

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed
1:16:14 PM: Task execution finished 'downloadAndUnzipFile'.

Is this expected, or is it a bug? If it is a bug, then where? In my script?

My build.gradle.kts looks like this

import de.undercouch.gradle.tasks.download.Download

group = "org.example"
version = "1.0-SNAPSHOT"

plugins {
    id("de.undercouch.download").version("4.0.4")
}

tasks {
    val downloadZipFile by registering(Download::class) {
        val destDir = buildDir.resolve("downloads")

        doFirst {
            destDir.mkdirs()
        }

        src("https://github.com/michel-kraemer/gradle-download-task/archive/1.0.zip")
        dest(destDir)
    }

    val downloadAndUnzipFile by registering(Copy::class) {
        dependsOn(downloadZipFile)
        from(downloadZipFile.get().outputFiles.map { zipTree(it) })
        into(buildDir)
    }
}
user7610
  • 25,267
  • 15
  • 124
  • 150

0 Answers0