title: Directory filtering Maven
body: <p>I want to filter directory and its content based on profile. Here is my pom.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;build&gt;
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
              &lt;filtering&gt;true&lt;/filtering&gt;
              &lt;targetPath&gt;properties&lt;/targetPath&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
      &lt;filters&gt;
          &lt;filter&gt;src/main/resources/${env}/ucm.properties&lt;/filter&gt;
      &lt;/filters&gt;
  &lt;/build&gt;
  
  &lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;int&lt;/id&gt;
          &lt;properties&gt;
              &lt;env&gt;int&lt;/env&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;uat&lt;/id&gt;
          &lt;properties&gt;
              &lt;env&gt;uat&lt;/env&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;stag&lt;/id&gt;
          &lt;properties&gt;
              &lt;env&gt;stag&lt;/env&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;prod&lt;/id&gt;
          &lt;properties&gt;
              &lt;env&gt;prod&lt;/env&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>And this is my project structure:</p>
  
  <p><img src="https://i.stack.imgur.com/hmEju.png" alt="enter image description here"></p>
  
  <p>But when it is building the jar it is copying all the folders (int, uat, stag, prod) inside it. </p>
  
  <p>How can I solve the issue?</p>