pappus pappus - 1 year ago 352
Java Question

Configure Sonar to exclude files from Maven pom.xml

I have a project configured in maven and the code analysis is done by SonarQube.

I am trying to configure SonarQube in the pom.xml file to exclude a few files from the code analysis. Those files can be identified by their class names, they contain the underscore character before the extension (they are metamodel classes). Below I give the part of the pom.xml file where I try to exclude them:


However, the above code does not work. Is there a way to configure SonarQube from my pom.xml file to ignore those files when analysing the source code?

Thank you in advance.

Answer Source

Sonar exclusions (like other sonar properties) have to be added to the <properties> section of the POM file. Like so (example from excluding jOOQ autogenerated code from current project):

    <sonar.exclusions>org/binarytherapy/generated/**/*, **/</sonar.exclusions>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download