You may have ordering issue in your script, as you configure the task prior to configuring the source sets to include the integrationTest type. Gradle splits the build into n init (bootstrap), configure, and execution phase. The script is configured in order, so by moving the jacocoRootReport task near the bottom it might just “work”. Its one of the few quirks of using a scripting language than a pure meta model.
It might be due to jacocoRootReport having a dependency on subprojects.test and not also subprojects.integrationTest. Perhaps integrationTest output is not being captured or getting overwritten. The first step is to see if the individual project’s report comes out properly. If so then you can debug the aggregation.
the execution report is coming out good i think cause in the folder i have an integrationTest.exec and a test.exec.
when running the JacocoRootReport task and changing its dependency to subproject.integrationTest i see no difference. When running the task with the debug flag gives me in the log:
22:53:34.361 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:jacocoReport] Loading execution data file /Users/Thomas/Documents/code/Java/lift/lift-controller/build/jacoco/test.exec
but in that same folder there is a “integrationTest.exec” that it doesnt seem to find. Its like it is hardcoded to just find test.exec. I dont get anything of this, its so poorly documented all of this.
If you are using Sonarqube you must first merge the Jacoco execution data and then tell it to use that instead of the individual exec files generated by each submodule.
First, we define a global coverage file output for our test reports (allTestCoverageFile).
Then we need to tell Sonarqube to use that file (using sonar.jacoco.reportPaths). But notice we also have to do it in the subprojects closure. This is extremely important. Don’t miss it.
Finally, we create a custom task that extends from JacocoMerge (an incubating class from the Jacoco plugin), that merges all the test coverage reports from all projects (executionData) into our allTestCoverageFile.