title: Is it possible to exclude (or include) classes or resources on a per profile basis in Maven?
body: <p>I have two maven profiles P1 and P2 and what I want to do is that depending on the profile I use to build my project, certain resources should be excluded.</p>
  
  <p>For example</p>
  
  <pre><code>&lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;P1&lt;/id&gt;
          &lt;properties&gt;
              &lt;app.home&gt;Path to project home&lt;/app.home&gt;
              &lt;exclude&gt;src/main/java/foo/*.*&lt;/exclude&gt; &lt;!-- need to exclude all files in src/main/java/foo in this profile --&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;P2&lt;/id&gt;
          &lt;properties&gt;
              &lt;app.home&gt;Path to project home&lt;/app.home&gt;
              &lt;exclude&gt;src/main/java/bar/*.*&lt;/exclude&gt; &lt;!-- need to exclude all files in src/main/java/bar in this profile--&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>So, here what I want to do is to exclude all files in src/main/java/foo/ when I build using the P1 profile and exclude all files in src/main/java/bar when I build using the P2 profile.</p>
  
  <p>Is this possible and if not is there any alternative?</p>