尝试按照此处的说明进行操作。我的build.gradle
样子是这样的(有一些修剪):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.scoverage:gradle-scoverage:1.0.9'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'scoverage'
dependencies {
compile('org.scala-lang:scala-library:2.11.6')
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.0.4', 'org.scoverage:scalac-scoverage-runtime_2.11:1.0.4'
}
}
project(':davinci-server') {
// SNIP
}
当我跑步时./gradlew testScoverage
,事情开始变得可疑。
:davinci-server:compileScoverageJava UP-TO-DATE
:davinci-server:compileScoverageScala
:davinci-server:processScoverageResources UP-TO-DATE
:davinci-server:scoverageClasses
:davinci-server:compileTestScoverageJava UP-TO-DATE
:davinci-server:compileTestScoverageScala UP-TO-DATE
:davinci-server:processTestScoverageResources UP-TO-DATE
:davinci-server:testScoverageClasses UP-TO-DATE
:davinci-server:testScoverage UP-TO-DATE
由于这是我第一次运行任何与覆盖率相关的任务,我不希望有这么多任务是UP-TO-DATE
.
该scoverageClasses
任务似乎运行良好,并且已将多个.class
文件放入davinci-server/build/classes/scoverage
. 似乎没有生成报告,./gradlew reportScoverage
只是被跳过,因为task onlyIf is false
.
所以我跑./gradlew --debug testScoverage
了,起初我没有看到任何提示。也许您会在本节中看到一些有趣的东西,但我没有:
14:42:31.709 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :davinci-server:testScoverageClasses (Thread[Daemon worker Thread 40,5,main]) started.
14:42:31.709 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :davinci-server:testScoverageClasses
14:42:31.709 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':davinci-server:testScoverageClasses'
14:42:31.709 [INFO] [org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter] Skipping task ':davinci-server:testScoverageClasses' as it has no actions.
14:42:31.709 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':davinci-server:testScoverageClasses'
14:42:31.709 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :davinci-server:testScoverageClasses UP-TO-DATE
14:42:31.709 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :davinci-server:testScoverageClasses (Thread[Daemon worker Thread 40,5,main]) completed. Took 0.0 secs.
14:42:31.710 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :davinci-server:testScoverage (Thread[Daemon worker Thread 40,5,main]) started.
14:42:31.710 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :davinci-server:testScoverage
14:42:31.710 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':davinci-server:testScoverage'
14:42:31.710 [DEBUG] [org.scoverage.ScoverageExtension] classpath, testSourceSet.runtimeClasspath: file collection
14:42:31.710 [DEBUG] [org.scoverage.ScoverageExtension] testClassesDir, testSourceSet.output.classesDir: /Users/coryklein/domo/davinci/davinci-server/build/classes/testScoverage
14:42:31.710 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':davinci-server:testScoverage' is up-to-date
14:42:31.710 [DEBUG] [org.scoverage.ScoverageExtension] testClassesDir, testSourceSet.output.classesDir: /Users/coryklein/domo/davinci/davinci-server/build/classes/testScoverage
14:42:31.712 [DEBUG] [org.scoverage.ScoverageExtension] classpath, testSourceSet.runtimeClasspath: file collection
// SNIP
14:42:31.967 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Skipping task ':davinci-server:testScoverage' as it is up-to-date (took 0.257 secs).
14:42:31.967 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':davinci-server:testScoverage'
14:42:31.967 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :davinci-server:testScoverage UP-TO-DATE
14:42:31.967 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :davinci-server:testScoverage (Thread[Daemon worker Thread 40,5,main]) completed. Took 0.257 secs.
然而,在调试输出的其他地方,我确实找到了这个 gem:
14:42:31.116 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':davinci-server:compileScoverageJava'
14:42:31.116 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/coryklein/domo/davinci/davinci-server/src/scoverage/java', not found
14:42:31.116 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/coryklein/domo/davinci/davinci-server/src/main/java', not found
14:42:31.116 [INFO] [org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter] Skipping task ':davinci-server:compileScoverageJava' as it has no source files.
14:42:31.116 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':davinci-server:compileScoverageJava'
看起来compileScoverageJava
正在被跳过,因为它在 中找不到任何源文件davinci-server/src/scoverage/scala
,但我终其一生都无法弄清楚为什么它会在那里寻找:我的源代码在davinci-server/src/main/scala
其中,而 gradle 知道它,该死!
我已经尝试编译我自己的gradle-scoverage
插件版本,其中到处都是logger.debug
左右声明,但找不到src/scoverage
路径来自哪里或任何其他关于为什么覆盖不起作用的指示。
有谁知道我可能哪里出错了?