scoverage/gradle-scoverage

Included build task ':reportScoverage' was never scheduled for execution.

marcintustin opened this issue · 16 comments

I get the error "Included build task ':reportScoverage' was never scheduled for execution.", with the following output from gradle:

FVFWX1KTHV2H:nsr-to-parquet marcintustin$ gradle clean test

> Task :compileScala
Pruning sources from previous analysis, due to incompatible CompileSetup.

> Task :compileTestScala
Pruning sources from previous analysis, due to incompatible CompileSetup.

FAILURE: Build failed with an exception.

* What went wrong:
Included build task ':reportScoverage' was never scheduled for execution.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 13s
4 actionable tasks: 4 executed

The only thing unusual about this project is that settings.gradle includes the line:

includeBuild '../../generic-ingest'

Please advise. Happy to provide more details.

Please could you provide an example repository? There's nothing immediately obvious from the above.

Thanks,
Stu

s4nk commented

I'm seeing something similar, also in a project using composite builds. Building the same project without composite builds works fine.

Works fine for me.

@marcintustin @s4nk Please provide us with more information on your builds; i.e, build.gradle files, settings.gradle files, and general directory structure.

@eyalroth I'm facing the same issue on a Jekins instance where we're testing 4 different projects as a composite build. Please find additional information below. I'm using the recently published version of the plugin. Please let me know if you need any other or more information

Debug-Log:

23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Included build task ':reportScoverage' was never scheduled for execution.
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]  Run with --scan to get full insights.
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] java.lang.IllegalStateException: Included build task ':reportScoverage' was never scheduled for execution.
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.composite.internal.DefaultIncludedBuildController.getTaskState(DefaultIncludedBuildController.java:271)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.composite.internal.DefaultIncludedBuildTaskGraph.getTaskState(DefaultIncludedBuildTaskGraph.java:63)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.TaskNodeFactory$TaskInAnotherBuild.isComplete(TaskNodeFactory.java:151)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.TaskNode.allDependenciesComplete(TaskNode.java:41)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultExecutionPlan.allDependenciesComplete(DefaultExecutionPlan.java:688)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultExecutionPlan.selectNext(DefaultExecutionPlan.java:546)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$2.transform(DefaultPlanExecutor.java:176)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$2.transform(DefaultPlanExecutor.java:163)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.internal.resources.DefaultResourceLockCoordinationService.withStateLock(DefaultResourceLockCoordinationService.java:45)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:163)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
23:02:16.426 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
23:02:16.427 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
23:02:16.427 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
23:02:16.427 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
23:02:16.427 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org

Folder Structure:
root

├── main_project
├── subproject1
├── subproject2
└── subproject3

Executed Command:

gradle -p main_project --parallel --include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3 --refresh-dependencies clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest allTests reportScoverage jacocoTestReport jacocoTestCoverageVerification

build.gradle (excerpt):

plugins {
	id "com.jfrog.artifactory" version "4.9.7"
	id 'groovy' // groovy support
	id 'java' // java support
	id 'scala' // scala support
	id 'application' // creates a JVM executable
	id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
	id 'pmd' // code check, working on source code
	id 'com.github.spotbugs' version '2.0.0' // code check, working on byte code
	id 'com.diffplug.gradle.spotless' version '3.24.2'// code format
	id 'com.simonharrer.modernizer' version '1.6.0-1' // detect deprecated APIs
	id 'com.github.onslip.gradle-one-jar' version '1.0.5' // pack a self contained jar
	id "de.undercouch.download" version "3.4.3" // downloads plugin
	id "kr.motd.sphinx" version "2.5.0" // documentation generation
	id "com.github.johnrengelman.shadow" version "5.1.0" // fat jar
	id 'jacoco' // java code coverage plugin
	id "org.sonarqube" version "2.7.1" // sonarqube
	id "org.scoverage" version "4.0.0" // scala code coverage scoverage
}

ext {
	//version (changing these should be considered thoroughly!)
	hibernateVersion = '5.3.3.Final'
	unitsOfMeasurementVersion = '1.0.8'
	javaVersion = JavaVersion.VERSION_1_8

	scalaVersion = '2.13' // for all plugins
	scalaBinaryVersion = '2.13.1' // for scala itself
	akkaVersion = '2.5.23'
	tscfgVersion = '0.9.9'
	slf4jVersion = '1.7.26'

	scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
	mainClass = 'INTERNAL MAIN CLASS'
}

apply from: scriptsLocation + 'pmd.gradle'
apply from: scriptsLocation + 'spotbugs.gradle'
apply from: scriptsLocation + 'spotless.gradle'
apply from: scriptsLocation + 'modernizer.gradle'
apply from: scriptsLocation + 'checkJavaVersion.gradle'
apply from: scriptsLocation + 'tscfg.gradle' // config tasks
apply from: scriptsLocation + 'sphinx.gradle' // documentation tasks + configuration
apply from: scriptsLocation + 'tests.gradle' // tasks for tests
apply from: scriptsLocation + 'jacoco.gradle' // jacoco java code coverage
apply from: scriptsLocation + 'sonarqube.gradle' // sonarqube config
apply from: scriptsLocation + 'scoverage.gradle' // scoverage scala code coverage

configurations {
	scalaCompilerPlugin
}

repositories {
	mavenLocal() //searches in local maven repository, typically ~/.m2/repository
	jcenter() //searches in bintray's repository 'jCenter', which contains Maven Central
	maven { INTERNAL REPO}
	maven { url 'https://jade.tilab.com/maven/' } // Maven repository for jade
	maven { url 'https://www.jitpack.io' } // allows github repos as dependencies
}


dependencies {
	// ie³ internal repository
	compile('edu.ie3:utils:+') {
		exclude group: 'org.slf4j', module: 'slf4j-api'
	}
	compile('edu.ie3:datamodel:+') {
		exclude group: 'org.slf4j', module: 'slf4j-api'
	}
	compile('edu.ie3:powerflow:+') {
		exclude group: 'org.slf4j', module: 'slf4j-api'
	}

	// logging
	compile "org.slf4j:slf4j-api:${slf4jVersion}"  // slf4j wrapper
	compile 'com.lmax:disruptor:3.4.2' // async logging
	compile 'org.apache.logging.log4j:log4j-api:+' // log4j
	compile 'org.apache.logging.log4j:log4j-core:+' // log4j
	compile 'org.apache.logging.log4j:log4j-slf4j-impl:+' // log4j -> slf4j

	compile "com.typesafe.scala-logging:scala-logging_${scalaVersion}:+" // akka scala logging
	compile group: 'com.typesafe.scala-logging', name: 'scala-logging-slf4j_2.11', version: '2.1.2'// scala logging
	compile "org.slf4j:log4j-over-slf4j:${slf4jVersion}" // slf4j -> log4j

	// hibernate
	compile 'org.hibernate:hibernate-core:' + hibernateVersion
	compile 'org.hibernate:hibernate-entitymanager:' + hibernateVersion
	compile 'org.hibernate:hibernate-ehcache:' + hibernateVersion
	compile 'net.sf.ehcache:ehcache:2.10.4'
	compile 'org.hibernate:hibernate-c3p0:' + hibernateVersion
	compile 'org.hibernate:hibernate-spatial:' + hibernateVersion // for supporting PostGIS geo related information

	// database
	compile 'net.sourceforge.jtds:jtds:+'
	compile 'org.postgresql:postgresql:+'
	compile 'mysql:mysql-connector-java:+'

	// testing
	testCompile 'junit:junit:+'
	testCompile 'org.spockframework:spock-core:1.3-groovy-+'
	testCompile 'cglib:cglib-nodep:+' // enables mocking of classes (in addition to interfaces)
	compile 'org.mockito:mockito-core:+' // mocking framework

	compile 'com.tilab.jade:jade:+' // multi agent system
	compile 'javax.measure:unit-api:+'
	compile 'org.apache.commons:commons-math3:+' // apache commons math3
	compile 'tec.uom:uom-se:' + unitsOfMeasurementVersion // quantities
	compile 'org.apache.commons:commons-csv:+'
	compile 'org.apache.commons:commons-lang3:+' // for HashCodeBuilder
	compile 'com.rabbitmq:amqp-client:+'
	compile 'com.github.johanneshiry:ascii-graphs:v0.0.8' // asci graph plotting in terminal for debugging
	compile('com.googlecode.matrix-toolkits-java:mtj:+')
	compile 'com.healthmarketscience.jackcess:jackcess:+' // for xml parsing
	compile 'javax.xml.bind:jaxb-api:+' // xml parsing
	compile 'commons-io:commons-io:+' // I/O functionalities
	compile 'com.opencsv:opencsv:+' // for csv parsing
	compile 'org.scalanlp:breeze_2.13:1.0' // scientific calculations (http://www.scalanlp.org/)

	// NEW scala libs //
	// CORE Akka //
	implementation group: 'com.typesafe.akka', name: "akka-actor_${scalaVersion}", version: akkaVersion
	implementation group: 'com.typesafe.akka', name: "akka-slf4j_${scalaVersion}", version: akkaVersion
	implementation group: 'com.typesafe.akka', name: "akka-cluster_${scalaVersion}", version: akkaVersion
	implementation group: 'com.typesafe.akka', name: "akka-contrib_${scalaVersion}", version: akkaVersion
	compile group: 'com.typesafe.akka', name: "akka-cluster-sharding_${scalaVersion}", version: akkaVersion
	compile group: 'com.typesafe.akka', name: "akka-cluster-tools_${scalaVersion}", version: akkaVersion

	// CORE Scala //
	compile "org.scala-lang:scala-library:${scalaBinaryVersion}"

	// TEST Scala //
	testCompile group: 'org.scalatest', name: "scalatest_${scalaVersion}", version: '3.0.8'
	testRuntime "org.pegdown:pegdown:1.6.0" // HTML report for scalatest
	testCompile group: 'com.typesafe.akka', name: "akka-testkit_${scalaVersion}", version: akkaVersion // akka testkit

	// config //
	implementation 'com.typesafe:config:+'
	compile('com.github.carueda:tscfg:v' + tscfgVersion)

	// cmd args parser //
	compile "com.github.scopt:scopt_${scalaVersion}:+"

	// https://mvnrepository.com/artifact/com.google.guava/guava
	compile group: 'com.google.guava', name: 'guava', version: '28.0-jre'


	// code style buildscript plugins
	spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:+' // java spotbugs

	compile "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.1" // scala scapegoat
	scalaCompilerPlugin "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.1" // scala scapegoat
}

// scapegoat hook configuration
// https://github.com/sksamuel/scapegoat
// using compileScala instead of tasks.withType(ScalaCompile) prevents applying scapegoat to scala test classes
// see https://docs.gradle.org/current/userguide/scala_plugin.html#sec:configure_scala_classpath for details
compileScala {
	scalaCompileOptions.additionalParameters = [
			"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
			"-P:scapegoat:dataDir:" + buildDir + "/reports/scapegoat/src/",
			"-P:scapegoat:ignoredFiles:.*/SimonaConfig.scala" // see scapegoat-sbt page for this param
	]
}

// separate scapegoat report for test classes
compileTestScala {
	scalaCompileOptions.additionalParameters = [
			"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
			"-P:scapegoat:dataDir:" + buildDir + "/reports/scapegoat/testsrc/"
	]
}

wrapper {
	gradleVersion = '5.4.1'
}

tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}

settings.gradle:

rootProject.name = 'XXXXX'

@johanneshiry could you provide the build and settings files for all of the projects (subproject1, subproject2, etc)?

My guess would be that the plugin is defined only on some projects but not all, and therefore invoking the entire composite build with reportScoverage causes this exception. It might also be that this only happens with --parallel, and that this error is non-deterministic? These are all speculations.

thanks for the fast reply @eyalroth! you're right the plugin is only defined in subproject1 as this is the only one that also contains scala code. subproject2 and subproject3 are java-only projects and hence there is no need for a scala code coverage check (neither is there a scalaCompile task which is needed by reportScoverage as far as I know?)

This leads me to the following two questions:

  • do I need to add the plugin to all subprojects, even if they don't contain scala code? Won't this cause any problems then due to the lack of the compileScala task?
  • is there any way to execute reportScoverage in mainproject and subproject1 only while using a single command like the one we're currently using?

I'll try to execute a the command without --parallel asap and will report back.

update 1
when I remove the --include-build commands totally but keep the --parallel it works as expected. As soon as I add --include-build again it complains again with Included build task ':reportScoverage' was never scheduled for execution.. When I do this, it doesn't matter if the project that is included with --include-build contains the :reportScoverage-task (or scala code) or not.

update 2
when I keep --include-build withouth calling :reportScoverage it even fails with the same error message.
Command was: gradle -p simona --parallel --include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3 clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest allTests jacocoTestReport jacocoTestCoverageVerification

update3
it seems like the the test gradle task is causing the trouble. When I run scala specs only (scala tests only, command script below) it works without any errors. When I run test (java tests only, command script below) it fails with the known error.

spec task

// Task to run scala tests, as Scala tests are not picked up by gradle by default
task spec(dependsOn: ['testClasses'], type: JavaExec) {
	main = 'org.scalatest.tools.Runner'
	args = ['-R', 'build/classes/scala/test', '-h', 'build/reports/tests/scalatest', '-oD']
	classpath = sourceSets.test.runtimeClasspath
}
build.dependsOn spec

test task
test {
// by default we don't want to run integration tests
filter {
excludeTestsMatching '*IT'
}
}

commands that fail

gradle -p simona --parallel --include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3 clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest spec :test -x reportScoverage
gradle -p simona --parallel --include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3  clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest :test -x reportScoverage
gradle -p simona --parallel --include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3  clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest :test

command that works (but neglect java tests and hence is not an option)

gradle -p simona --parallel ---include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3 clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest 
gradle -p simona --parallel ---include-build ../subproject1 --include-build ../subproject2 --include-build ../subproject3 clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest spec

do I need to add the plugin to all subprojects, even if they don't contain scala code? Won't this cause any problems then due to the lack of the compileScala task?

The plugin should only be applied on modules with Scala code or on parent modules (in a multi-module project) that aggregate the reports of sub-modules with Scala code. I don't believe there should be a different behavior for composite builds; i.e, only applye plugin on the modules inside your projects that require it.

is there any way to execute reportScoverage in mainproject and subproject1 only while using a single command like the one we're currently using?

With a multi-module project build, all you have to do is add the task name to the command, and gradle will make sure to run the task only in the relevant modules that have it. I'm not sure why the composite build behaves differently.

when I remove the --include-build commands totally but keep the --parallel it works as expected.

Did you try running with --include-build but without --parallel?

When I do this, it doesn't matter if the project that is included with --include-build contains the :reportScoverage-task (or scala code) or not.

But you always executed from the "mainproject" which has the plugin and the task, correct?


Could you provide some graph trees for the commands you're trying? You can just add --dry-run (it should be fast as it doesn't execute the tasks).

Honestly though, the best thing would be to create a repository with minimal conditions needed for reproduction. I know it's a lot to ask, but that would be the easiest way to identify the problem.

@eyalroth I'm traveling the whole week and don't know if I can provide answers to your questions and a sample project within this week. Will report back asap.

@johanneshiry It's ok, there's no rush. Travel safe :)

@eyalroth I just created a sample project which reproduces the error - you can find it here

Did you try running with --include-build but without --parallel?

yep - didn't make any difference :-(

But you always executed from the "mainproject" which has the plugin and the task, correct?

yep

Could you provide some graph trees for the commands you're trying? You can just add --dry-run (it should be fast as it doesn't execute the tasks).
This is the graph the from the sample project which also reproduces the issue

> Task :subproject1:checkJavaVersion
> Task :clean
> Task :checkJavaVersion
> Task :subproject1:compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :subproject1:compileGroovy NO-SOURCE
> Task :processTestResources NO-SOURCE

> Task :subproject1:compileScala
Pruning sources from previous analysis, due to incompatible CompileSetup.

> Task :subproject1:processResources
> Task :subproject1:classes
> Task :subproject1:jar
> Task :compileJava NO-SOURCE
> Task :compileGroovy NO-SOURCE

> Task :compileScala
Pruning sources from previous analysis, due to incompatible CompileSetup.

> Task :classes
> Task :compileTestJava NO-SOURCE
> Task :compileTestGroovy NO-SOURCE
> Task :compileTestScala NO-SOURCE
> Task :testClasses UP-TO-DATE

@eyalroth @maiflai can you give any update on this issue? Is there anything else I can support you solving this issue? We would love to use the plugin over here :-)

@johanneshiry The good news is that I've been able to identify the culprit, have reduced the sample project into a much simpler structure and added tests for this in #132.

The bad news is that it seems that this is caused due to a bug with composite builds (gradle/gradle#11747).

Furthermore, your build is incompatible with scoverage for other reasons as well; (a) it uses Scala 2.13, which is currently not working; (b) it uses ScalaTest instead of JUnit, which I'm not sure is compatible with this plugin. For more information on how to setup scala tests using JUnit, check out my example project.

On ScalaTest - I think that if you take the same approach as the gradle-scalatest plugin it might work a little better?

That plugin replaces the implementation of the Test task, which means that the gradle-scoverage plugin can then modify the configuration of the Test task.

I think the sample project uses the Test task as a placeholder to anchor other tasks, which means that they cannot be reconfigured appropriately.

On the 2.13 issue, for my part, I'm still looking at a way to make this all just work. Sorry.