gpt4 book ai didi

gradle - Gradle:我如何依赖资源任务对象?

转载 作者:行者123 更新时间:2023-12-03 03:52:07 26 4
gpt4 key购买 nike

在java war项目中,我具有http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html的代码,以确保创建了一些目录。

task resources << {
mkdir "generated"
}

task acct(type: Exec) {
dependsOn resources
// ...
}

这样,构建将失败:
Could not determine the dependencies of task ':acct'.
> Cannot convert org.gradle.api.internal.resources.DefaultResourceHandler@1d65e511 to
a task.
The following types/formats are supported:
- A String or CharSequence task name or path
- A Task instance
- A Buildable instance
- A TaskDependency instance
- A Closure instance that returns any of the above types
- A Callable instance that returns any of the above types
- An Iterable, Collection, Map or array instance that contains any of the above types

我以为如果不使用引号,就在使用任务实例(上面支持的列表中的第二项)。

如果我在引号中使用 "resource",则可以使用。如果我将任务重命名为 res,那么它也可以不带引号而工作;按照 http://www.gradle.org/docs/current/userguide/tutorial_using_tasks.html#sec:task_dependencies

为什么会这样?声明此依赖项的推荐方法是什么?

最佳答案

resources将解析为project.resources。要引用任务,可以使用tasks.resources或(如您所说的)"resources"

关于gradle - Gradle:我如何依赖资源任务对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25511240/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com