title: Maven: Customize web.xml of web-app project
body: <p>I have a web application Maven project, and I want to customize the web.xml file depending on the Profile that is running. I am using the Maven-War-plugin, which allows me to define a "resources" directory, where the files may be filtered. However, filtering alone is not sufficient for me.</p>
  
  <p>In more detail, I want to <strong>include (or exclude)</strong> the whole section on security, depending on the profile I an running. This is the part:</p>
  
  <pre class="lang-xml prettyprint-override"><code>....
  ....
  
  &lt;security-constraint&gt;
  
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;protected&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/pages/*.xhtml&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/pages/*.jsp&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
  
      &lt;auth-constraint&gt;
          &lt;role-name&gt;*&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  
      &lt;/security-constraint&gt;
          &lt;login-config&gt;
          &lt;auth-method&gt;${web.modules.auth.type}&lt;/auth-method&gt;
          &lt;realm-name&gt;MyRealm&lt;/realm-name&gt;
      &lt;/login-config&gt;
  
  &lt;security-constraint&gt;
  
  ....
  ....
  </code></pre>
  
  <p>If this is not done easily, is there a way to have two web.xml files and select the appropriate one depending on the profile?</p>