Using SonarQube 7.9:
Using the sonar maven plugin the code coverage is only calculated for the code in src/main/java, but not for the generated code in target/generated-sources/annotations.
For me this means the code coverage metric is wrong because all the code that is included in the build artifact should be considered to calculate the code coverage independent if it is manual or generated code.
We use the following configuration now:
<sonar.sources>pom.xml,src/main,${project.build.directory}/generated-sources/annotations</sonar.sources>
<sonar.cpd.exclusions>\*\*/generated-sources/\*\*/*.java</sonar.cpd.exclusions>
<sonar.scm.exclusions.disabled>true</sonar.scm.exclusions.disabled>
The second one is needed to ignore code duplication in generated code.
The third one is needed as the target directory is normally part of the .gitignore file.
It would improve the out of the box experience with sonar if this would be handled correctly.
Kind regards,
Michael