title: How to exclude java classes from being compiled in maven with annotation
body: <p>I already have a <strong>working</strong> solution where I can specify with maven which classes to not compile when using a particular maven profile.</p>
  
  <p>But I would like to use a general solution and use an annotation instead </p>
  
  <p>The current solution that I have is like</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;!-- Exclude some web services used only for internal testing --&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;configuration&gt;
          &lt;optimize&gt;true&lt;/optimize&gt;
          &lt;excludes&gt;
              &lt;exclude&gt;**/something/*ClassPattern.java&lt;/exclude&gt;
          &lt;/excludes&gt;
          &lt;testExcludes&gt;
              &lt;exclude&gt;**/something/*ClassPatternTest.java&lt;/exclude&gt;
          &lt;/testExcludes&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>But Some thing like </p>
  
  <pre><code>@NotCompiledForProduction 
  </code></pre>
  
  <p>would be rather nice on top of a class.</p>
  
  <p>It seems to me that this might be hard (or impossible to do) without changing maven's behaviour. That is not the scope here. And this kind of annotation </p>