title: How to exclude certain classes from being included in the code coverage? (Java)
body: <p>I could already exclude the classes with sonar cube report by adding this in the  tag of my POM file.</p>
  
  <pre><code> &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;sonar.exclusions&gt; 
              /src/main/java/com/example/org/test/mainpackage/message/**/*
              ,
              /src/main/java/com/example/org/test/mainpackage/security/jwt/**/*
              ,
              /src/main/java/com/example/org/test/mainpackage/security/services/**/*
              ,
              /src/main/java/com/example/org/test/mainpackage/controller/AuthRestAPIs.java
              ,
              /src/main/java/com/example/org/test/mainpackage/controller/TestRestAPIs.java
          &lt;/sonar.exclusions&gt;
      &lt;/properties&gt;
  </code></pre>
  
  <p>However the same code when run locally to test the code coverage is not working at all. </p>
  
  <p>Where do I set this up programmatically with Maven &amp; Spring Boot ?. </p>
  
  <p>I could already exclude the classes I want via the </p>
  
  <blockquote>
    <p>Settings > Build, Execution, Deployment > Excludes > [Class(es) to be
    excluded]</p>
  </blockquote>
  
  <p>or through</p>
  
  <blockquote>
    <p>Edit Configurations > Select Code Coverage tab > then adding the
    package or class I want to be excluded or include only in the code
    coverage report.</p>
  </blockquote>
  
  <p>What I want is coding the classes to be excluded i.e in the pom file like I did with exclusion of code for sonar qube.</p>
  
  <p>To make it short. How do I do this programmatically?.</p>
  
  <p>Reason why I wanted to this programmatically is that, the above two steps I did to exclude the files from being reported in the code coverage is that no files was included in all of my project that I could push in the repository so that changes i made for exclusions will reflect in all those who will pull from the git repository. With no files or configurations added that I could push and reflect to all in the repo. THis means that my exclusions will only work locally and not work on others. Right?. So here I am asking for a way to do programmatically like putting the exclusions in a POM file. </p>