title: How can I create a Maven build profile to conditionally copy files?
body: <p>I new to maven and I am trying to create pom.xml to build the war files for different environment using profiles</p>
  
  <p>So I created the build target</p>
  
  <pre><code>&lt;build&gt;
  &lt;finalName&gt;myacct_okc&lt;/finalName&gt;
  &lt;resources&gt;
    &lt;resource&gt;
      &lt;directory&gt;src/main/java&lt;/directory&gt;
      &lt;excludes&gt;
        &lt;exclude&gt;**/*.java&lt;/exclude&gt;
      &lt;/excludes&gt;
    &lt;/resource&gt;
    &lt;resource&gt;
      &lt;directory&gt;src/main/resources&lt;/directory&gt;
    &lt;/resource&gt;
    &lt;resource&gt;
      &lt;directory&gt;config/${environment}&lt;/directory&gt;
    &lt;/resource&gt;
   &lt;/resources&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>And then created the profiles for each environment</p>
  
  <pre><code>&lt;profiles&gt;
   &lt;profile&gt;
    &lt;id&gt;local&lt;/id&gt;
    &lt;activation&gt;
      &lt;activeByDefault&gt;false&lt;/activeByDefault&gt;
    &lt;/activation&gt;
    &lt;properties&gt;
      &lt;environment&gt;local&lt;/environment&gt;
    &lt;/properties&gt;
  &lt;/profile&gt;
  &lt;profile&gt;
    &lt;id&gt;jboss&lt;/id&gt;
    &lt;properties&gt;
      &lt;environment&gt;jboss&lt;/environment&gt;
    &lt;/properties&gt;
  &lt;/profile&gt;
  &lt;profile&gt;
    &lt;id&gt;dev&lt;/id&gt;
    &lt;properties&gt;
      &lt;environment&gt;dev&lt;/environment&gt;
    &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p></p>
  
  <p>and I create a config folder for each env</p>
  
  <pre><code>project root
  |-- src
  |   |-- main
  |   |   |-- java
  |   |   |-- resources
  |   |   |   |-- config.xml
  |   |   |   +-- config.properties
  |   |   |-- webapp
  |   |   |   |-- META-INF
  |   |   |   |   +--context.xml
  |   |   |-- config
  |   |   |   |-- local
  |   |   |   |   |--config.properties
  |   |   |   |   +--config.xml
  |   |   |   |-- jboss
  |   |   |   |   |--config.properties
  |   |   |   |   +--config.xml
  |   |   |   +-- dev
  |   |   |   |   |--config.properties
  |   |   |   |   +--config.xml
  +--pom.xml
  </code></pre>
  
  <p>Now when I run this pom.xml with any profile for e.g. jboss, the files form config/jboss folder are not getting copied ( or I mean the files in src/main/resources are not getting replaced).</p>
  
  <p>when I enabled the debug on on maven build I can see the copy getting executed.</p>
  
  <pre><code> [DEBUG] resource with targetPath null
   directory C:\Projects\workspace\myaccount_build_4\myaccount\config\jboss
   excludes []
   includes []
   [DEBUG] ignoreDelta true
   [INFO] Copying 2 resources
   [DEBUG] file config.xml has a filtered file extension
   [DEBUG] copy C:\Projects\workspace\myaccount_build_4\myaccount\config\jboss\config.xml to C:\Projects\workspace\myaccount_build_4\myaccount\target\classes\config.xml
   [DEBUG] file config.properties has a filtered file extension
   [DEBUG] copy C:\Projects\workspace\myaccount_build_4\myaccount\config\jboss\META-INF\config.properties to    C:\Projects\workspace\myaccount_build_4\myaccount\target\classes\META-INF\config.properties
  </code></pre>
  
  <p>But it is not replacing the files. The files are still the same as from src/main/resources.</p>
  
  <p>Maven version is 3.0.4</p>
  
  <p>Can someone help me what I am doing wrong ?</p>
  
  <p>I have looked at this <a href="https://stackoverflow.com/questions/12729513/how-to-overwrite-files-in-the-war-file-during-maven-build">question</a>. This provides a solution but I want to override the files rather then excluding them and then copy.  </p>