Setting up properly SonarQube's for Code Coverage
From SonarQube's documentation:
SonarSource analyzers do not run your tests or generate reports. They only import pre-generated reports.
A popular library for generating code coverage for Java is Jacoco.
SonarQube provides this guide to create and import Jacoco's reports.
Here is the working sonar-project.properties
file:
# SONAR CLOUD CONFIGS
sonar.host.url=https://sonarcloud.io
sonar.organization=xxx
sonar.projectKey=xxx
sonar.login=xxx
# SOURCES
sonar.java.source=12
sonar.sources=src/main/java
sonar.java.binaries=target/classes
sonar.sourceEncoding=UTF-8
# EXCLUSIONS
# (exclusion of Lombok-generated stuff comes from the `lombok.config` file)
sonar.coverage.exclusions = **/*Exception.java , **/MySpringBootApplication.java
# TESTS
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
sonar.junit.reportsPath=target/surefire-reports/TEST-*.xml
sonar.tests=src/test/java