Cobertura 任务未包含在 gradle 构建中

Cobertura task is not getting included as part of gradle build

我正在使用 gradle 进行构建。当我执行 "gradle clean build" 时,它会执行我所有的测试用例并构建成功。当我执行 gradle clean cobertura 时,它会生成我的 cobertura 报告。我想将 cobertura 报告集成为 gradle 构建的一部分。我在 build.gradle 中尝试了以下选项,但它给了我一个错误。

build{

 dependsOn cobertura

}

我得到的错误。对此有什么想法吗?

Could not determine the dependencies of task ':build'.
> Cannot convert net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated@528e5e38 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

cobertura 是扩展名。创建 cobertura 报告的任务称为 coberturaReport

所以你必须做:

build.dependsOn coberturaReport