4

Trying to follow the instructions here. My build.gradle looks like this (with some trimming):

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
}

When I run ./gradlew testScoverage though things start to look suspicious.

: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

Since this is the first time I've run anything scoverage related, I wouldn't expect so many tasks to be UP-TO-DATE.

The scoverageClasses task seems to have worked just fine, and it has put several .class files in davinci-server/build/classes/scoverage. No reports appear to be generated, and ./gradlew reportScoverage just gets skipped because task onlyIf is false.

So I run ./gradlew --debug testScoverage and at first I don't see any hints. Maybe you'll see something interesting in this section, but I didn't:

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.

However, looking elsewhere in the debug output, I did find this 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'

It looks like compileScoverageJava is being skipped because it can't find any source files in davinci-server/src/scoverage/scala, but I can't figure out for the life of me why it's looking there anyway: my source code is in davinci-server/src/main/scala and gradle knows it, dammit!

I've tried compiling my own version of the gradle-scoverage plugin that is littered with logger.debug statements left and right, but can't find where the src/scoverage path is coming from or any other indication as to why scoverage isn't working.

Does anybody have any idea where I may have gone wrong?

Cory Klein
  • 51,188
  • 43
  • 183
  • 243
  • Kust to note, compileScoverageJava is skipped because you don't have a java classes under src/main/java, but not scala, so it seems to be ok. Your scala classes will be tested by compileScoverageScala, I think. Have you tryied to modify your scala sources to make them build again? – Stanislav Dec 03 '15 at 02:49

0 Answers0