Gradle Build 找不到 testSrcDirs



我正在尝试为现有的 Java 项目运行 Gradle 构建,但我收到以下错误,该错误似乎与我的项目无关。

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myProject:test'.
> Could not get unknown property 'testSrcDirs' for task ':myProject:test' of type org.gradle.api.tasks.testing.Test.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

如何修复此错误?

如果您登陆此页面搜索 testSrcDir 异常,请尝试将 gradle clover 插件 jar 从 2.0.1 更新到最新版本。

如果无法更新版本,您也可以尝试此处建议的解决方法

test {
ext.testSrcDirs = project.sourceSets.test.java.srcDirs
}

对我来说,问题是我的项目需要使用 Gradle 2.x 构建,但我使用的是 Gradle 3.x。一旦我恢复了我的 Gradle 版本,构建就起作用了。

最新更新