title: How to make Sonar ignore some classes for codeCoverage metric?
body: <p>I have a Sonar profile in Maven. Everything works fine except the code coverage metric. I want to make Sonar ignore some classes only for the code coverage metric. I have the following profile:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;profile&gt;
      &lt;id&gt;sonar&lt;/id&gt;
      &lt;properties&gt;
          &lt;sonar.exclusions&gt;**/beans/jaxb/**&lt;/sonar.exclusions&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${maven.surefire.plugin.version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;redirectTestOutputToFile&gt;true&lt;/redirectTestOutputToFile&gt;
                      &lt;excludes&gt;
                          &lt;exclude&gt;**/*Suite*.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*RemoteTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*SpringTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*CamelTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*FunctionalTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*IntegrationTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*DaoBeanTest.java&lt;/exclude&gt;
                      &lt;/excludes&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;                    
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>Please help. I tried to add something like </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;exclude&gt;com/qwerty/dw/publisher/Main.class&lt;/exclude&gt;
  </code></pre>
  
  <p>but it didn't help</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have a correct Cobertura profile. I tried to add it to the Sonar profile, but still I have 53% instead about 95% like in the Cobertura profile</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;profile&gt;
      &lt;id&gt;sonar&lt;/id&gt;
      &lt;properties&gt;
          &lt;sonar.exclusions&gt;**/beans/jaxb/**&lt;/sonar.exclusions&gt;
          &lt;sonar.core.codeCoveragePlugin&gt;cobertura&lt;/sonar.core.codeCoveragePlugin&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${maven.surefire.plugin.version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;redirectTestOutputToFile&gt;true&lt;/redirectTestOutputToFile&gt;
                      &lt;excludes&gt;
                          &lt;exclude&gt;**/*Suite*.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*RemoteTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*SpringTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*CamelTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*FunctionalTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*IntegrationTest.java&lt;/exclude&gt;
                          &lt;exclude&gt;**/*DaoBeanTest.java&lt;/exclude&gt;
                      &lt;/excludes&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${cobertura.maven.plugin.version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;instrumentation&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;com/qwerty/dw/dao/*&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/domain/*&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/beans/**/*&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/daemon/exception/*&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/daemon/Main.class&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/sink/Main.class&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/publisher/Main.class&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/publisher/dao/*&lt;/exclude&gt;
                              &lt;exclude&gt;com/qwerty/dw/publisher/domain/*&lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/instrumentation&gt;
                      &lt;formats&gt;
                          &lt;format&gt;html&lt;/format&gt;
                      &lt;/formats&gt;
                      &lt;aggregate&gt;true&lt;/aggregate&gt;
                      &lt;check&gt;
                          &lt;haltOnFailure&gt;true&lt;/haltOnFailure&gt;
                          &lt;branchRate&gt;60&lt;/branchRate&gt;
                          &lt;lineRate&gt;60&lt;/lineRate&gt;
                          &lt;totalBranchRate&gt;60&lt;/totalBranchRate&gt;
                          &lt;totalLineRate&gt;60&lt;/totalLineRate&gt;
                      &lt;/check&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;clean&lt;/goal&gt;
                              &lt;goal&gt;check&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/profile&gt;
  </code></pre>