1

当我运行以下build.gradle.kts脚本时,第一次调用目标downloadAndUnzipFile时,当我使用干净的构建目录运行时,出现错误。

> 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.

如果我立即重新运行相同的任务,我现在就成功了

> 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'.

这是预期的,还是一个错误?如果它是一个错误,那么在哪里?在我的剧本中?

我的build.gradle.kts长相是这样的

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)
    }
}
4

0 回答 0