title: How to include specific files in war using maven
body: <p>I'm having some trouble trying to figure out a good way to control which resources to include in a war using maven. In my src/main/resources directory I have two files, logback.xml and logback-test.xml . What I want to be able to do is direct maven which of the two to include in the classpath based on the current maven profile. My initial thought was to define a property called log.config and then use that property in the configuration of maven-war-plugin. Something like:</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;3.3.1&lt;/version&gt;
              &lt;configuration&gt;
                      &lt;resource&gt;
                          &lt;directory&gt;src/main/resources&lt;/directory&gt;
                          &lt;filtering&gt;true&lt;/filtering&gt;
                          &lt;includes&gt;                          
                              &lt;include&gt;${log.config}&lt;/include&gt;                                    
                          &lt;/includes&gt;                             
                      &lt;/resource&gt;
                  &lt;/webResources&gt;
              &lt;/configuration&gt;
        &lt;/plugin&gt;
  </code></pre>
  <p>and a profile like</p>
  <pre><code>&lt;profile&gt;
          &lt;id&gt;test&lt;/id&gt;
          &lt;properties&gt;
              &lt;log.config&gt;logback-test.xml&lt;/log.config&gt;
          &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  <p>If I run the command</p>
  <blockquote>
  <p>mvn clean package -P test</p>
  </blockquote>
  <p>I still end up with both versions of the logback file in the resulting war. I also tried using</p>
  <pre><code>&lt;packagingIncludes&gt;${log.config}&lt;/packagingIncludes&gt;
  </code></pre>
  <p>with the same results.</p>
  <p>What am I doing wrong here? Is there a better way to include/exclude files without having to copy/paste the maven-war-plugin definition into all my profiles?</p>