Sonar multimodule with coverage logging File '<filename>' not found in project sources

Versions

  • SonarQube Server Enterprise Edition v2026.2.1 (121354)
  • Plugin version: 7.2.3.7755
  • jacoco packaged with gradle 9.4.1

Relevant config:

tasks.register("codeCoverageReport", JacocoReport) {
    subprojects { subproject ->
        subproject.plugins.withType(JacocoPlugin).configureEach {
            subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).configureEach { testTask ->
                if (testTask.extensions.getByType(JacocoTaskExtension).isEnabled()) {
                    sourceSets subproject.sourceSets.main
                    executionData(testTask)
                } else {
                    logger.warn('Jacoco extension is disabled for test task \'{}\' in project \'{}\'. this test task will be excluded from jacoco report.',testTask.getName(),subproject.getName())
                }
            }

            // To automatically run `test` every time `./gradlew codeCoverageReport` is called,
            // you may want to set up a task dependency between them as shown below.
            // Note that this requires the `test` tasks to be resolved eagerly (see `forEach`) which
            // may have a negative effect on the configuration time of your build.
            subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).forEach {
                rootProject.tasks.codeCoverageReport.dependsOn(it)
            }
        }
    }

    reports {
        xml.required = true
    }
}

And each module has org.sonarqube, jvm-test-suite and jacoco.

What is going wrong:
In our gitlab runners we are running the sonar gradle task. The logging for this tasks is too much for the runner and it cuts of the logging for the rest of the task. The log line that keeps repeating is: “File ‘’ not found in project sources”

What have i tried:
Setting sonar.coverage.jacoco.aggregateXmlReportPaths in each module
Setting sonar.coverage.jacoco.aggregateXmlReportPaths at top level only
Setting sonar.coverage.jacoco.xmlReportPaths in each module
Using the jacoco-report-aggregation plugin alongside these other solutions
I have also found a tmp solution by just piping the output into grep (e.g. | grep -v "File '[^']' not found in project sources"), but this is not really a good solution.

None of these solutions gave the desired result. I do believe it has something to do with the exclusions we use. We are excluding our generated file annotated with Generated. The excluded files seem to be logged as not found in project sources. So my guess is: jacoco generates a report on all files → sonar excludes some files but still finds these files in the coverage → log line output. OR: each module has the full (aggregated) report as their coverage → when sonar scans these modules it reads the coverage, but the sources do not have the files outside the module.

Hi,

Welcome to the community!

Based on these error messages, I guess (and it is a guess, without more context) the paths analysis is seeing in your coverage reports don’t match the paths it’s seeing during analysis.

The last paragraph of the docs section on adding coverage in a multi-module Maven project is relevant:

Please note that the import of aggregate report files depends on the value of sonar.sources analysis parameter pointing to the exact location where your Java sources. For example, if your project (or subproject) contains both Java and Kotlin sources, respectively under src/main/java and src/main/kotlin , then sonar.sources should include both folders expliclity (e.g. sonar.sources=src/main/java,src/main/kotlin ) rather than their shared common root (e.g. sonar.sources=src/main ).

 
Ann