尝试按照here的说明操作。我的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
由于这是我第一次与任何scoverage相关,我不会期望这么多任务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.
然而,在调试输出的其他地方,我找到了这个宝石:
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
中的任何源文件,但我无法弄清楚为什么会这样做&#39} ;无论如何看着那里:我的源代码在davinci-server/src/main/scala
并且gradle知道它,该死![/ p>
我已经尝试编译我自己版本的gradle-scoverage
插件,该插件左右散布着logger.debug
个语句,但无法找到src/scoverage
路径的位置来自或任何其他迹象表明为什么scoverage不起作用。
有没有人知道我哪里出错了?