title: Maven - Exclude class files from war
body: <p>I have :</p>
  
  <pre><code>src/main/java/com.tuto
  </code></pre>
  
  <ul>
  <li><code>Class1.java</code></li>
  <li><code>Class2.java</code></li>
  <li><code>Class3.java</code></li>
  </ul>
  
  <p>My pom is packaging a war.
  So in my war, in <code>WEB-INF/classes/com/tuto</code> I found the 3 classes.</p>
  
  <p>Now I want to exclude Class2.java</p>
  
  <p>I tried </p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;configuration&gt;
                &lt;excludes&gt;
                   &lt;exclude&gt;**/Class2.class&lt;/exclude&gt;
                &lt;/excludes&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>But it's not working.</p>
  
  <p>How can I do ?</p>
  
  <hr>
  
  <p>Ok, so like Aaron tell me, this is working :</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.1&lt;/version&gt;
      &lt;configuration&gt;
          &lt;packagingExcludes&gt;**/Class2.class&lt;/packagingExcludes&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>But ...</p>
  
  <p>Let's take the problem by the other side : I want to exclude all except Class1 and Class3</p>
  
  <p>So I tried </p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.1&lt;/version&gt;
      &lt;configuration&gt;
          &lt;packagingIncludes&gt;**/Class1.class,**/Class3.class&lt;/packagingIncludes&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>and this time it's not working.</p>