sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
One project scanned six ways with SonarQube 26.11: which setting decides coverage, and which patterns match nothing.

SonarQube does not read JaCoCo’s excludes. Files missing from JaCoCo’s
report count in SonarQube as uncovered. Set sonar.coverage.exclusions, with
source paths such as **/dto/**, and SonarQube leaves them out of coverage.
sonar.coverage.exclusions vs sonar.exclusions
| Setting | What SonarQube does with matching files |
|---|---|
sonar.coverage.exclusions | Still analysed for bugs and smells; left out of coverage |
sonar.exclusions | Left out of the whole analysis, issues included |
JaCoCo’s <excludes> | Nothing: SonarQube counts those files as uncovered |
We ran each setup with SonarQube Community Build 26.11, the SonarScanner for Maven 5.9 and JaCoCo 0.8.16, on a Maven project with five classes: two with tests, a DTO package and an application class with a nested class. Without exclusions SonarQube reported 39.4% coverage.
Exclude files from coverage
<properties>
<sonar.coverage.exclusions>**/dto/**,**/ShopApplication.java</sonar.coverage.exclusions>
</properties>
Coverage went to 81.3%: 8 of 10 lines and 5 of 6 branches, from Pricing
and Receipt only. The same value on the command line,
-Dsonar.coverage.exclusions=…, gave the same result.
It gave 81.3% whether or not JaCoCo excluded anything. SonarQube decides
coverage scope from its own setting; JaCoCo’s excludes only change JaCoCo’s
own HTML and its check goal. Keep both in step, or set only the SonarQube
one if SonarQube is your gate.
SonarQube found target/site/jacoco/jacoco.xml without being told. Set
sonar.coverage.jacoco.xmlReportPaths only for another path or for several
modules.
The same exclusions, two numbers
With JaCoCo excluding shop/dto/** and shop/ShopApplication*.class and no
SonarQube setting:
| Report | Coverage |
|---|---|
| JaCoCo’s own HTML | 8 of 10 lines (80%) |
| SonarQube | 46.4%: 8 of 22 lines, the excluded files at 0% |
SonarQube counted every line it considers executable in OrderDto.java and
ShopApplication.java as uncovered, because the report had no data for them.

Why your sonar.coverage.exclusions isn’t working
| What we tried | What happened |
|---|---|
shop/dto/**, shop/ShopApplication*.class | Nothing excluded: SonarQube matches source paths, not classes |
JaCoCo <excludes> only | 46.4%, the files counted as uncovered |
sonar.exclusions | 81.3%, but the files lost their bugs and smells too |

Patterns match source file paths from the project directory: **/dto/**
worked, package-style and class-file patterns did not. Separate several
patterns with commas.
What Supercov adds
npx supercov -- mvn test
npx supercov runs latest gaps
SonarQube shows one blended number per file. Supercov records which test covered each line, with branches and MC/DC, and names the missing case. See JaCoCo exclude for JaCoCo’s side and JaCoCo vs SonarQube coverage for how SonarQube blends lines and branches.
More coverage guides
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code