Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think you can do this in one step (actually, I'm surprised that Maven doesn't complain about your setup and wonder which one is applied) and I'd suggest to use profiles and maybe filtering to manage this use case. </p> <p>If your <code>web.xml</code> are really different, you could just put your maven-war-plugin configuration in two profiles. Or, better, you could merge them into something like this:</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-beta-1&lt;/version&gt; &lt;configuration&gt; &lt;webXml&gt;src/main/config/${env}/web.xml&lt;/webXml&gt; &lt;warName&gt;cas-test&lt;/warName&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>And set the <code>env</code> property in two profiles to pick up the right <code>web.xml</code> at build time.</p> <pre><code>&lt;profiles&gt; &lt;profile&gt; &lt;id&gt;uat&lt;/id&gt; &lt;properties&gt; &lt;env&gt;test&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>If your <code>web.xml</code> are similar (i.e. if only values differ in them), you could define properties and their values in two profiles and use filtering to apply them. Something like this:</p> <pre><code>&lt;profiles&gt; &lt;profile&gt; &lt;id&gt;env-uat&lt;/id&gt; &lt;activation&gt; &lt;property&gt; &lt;name&gt;env&lt;/name&gt; &lt;value&gt;uat&lt;/value&gt; &lt;/property&gt; &lt;/activation&gt; &lt;properties&gt; &lt;key1&gt;uat_value_key_1&lt;/key1&gt; &lt;keyN&gt;uat_value_key_n&lt;/keyN&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;profile&gt; &lt;id&gt;env-prod&lt;/id&gt; &lt;activation&gt; &lt;property&gt; &lt;name&gt;env&lt;/name&gt; &lt;value&gt;prod&lt;/value&gt; &lt;/property&gt; &lt;/activation&gt; &lt;properties&gt; &lt;key1&gt;prod_value_key_1&lt;/key1&gt; &lt;keyN&gt;prod_value_key_n&lt;/keyN&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;/profiles&gt; </code></pre> <p>Then activate one profile or the other by passing the env property on the command line, e.g.:</p> <pre><code>mvn -Denv=uat package </code></pre> <p>Another option would be to put the values into specific filters and pick up the right one at build time (like in <a href="http://www.jetbrains.net/devnet/thread/279955" rel="nofollow noreferrer">this post</a>).</p> <p>There are really many options but as I said, I don't think you can do this without runngin the build twice. </p> <p>More resources on profiles/filtering:</p> <ul> <li><a href="http://www.sonatype.com/books/maven-book/reference/profiles.html" rel="nofollow noreferrer">Maven Book: Chapter 11. Build Profiles</a></li> <li><a href="http://www.sonatype.com/books/maven-book/reference/resource-filtering-sect-description.html" rel="nofollow noreferrer">Maven Book: Chapter 15.3. Resource Filtering</a></li> <li><a href="http://maven.apache.org/guides/introduction/introduction-to-profiles.html" rel="nofollow noreferrer">Introduction to Build Profiles</a></li> <li><a href="https://stackoverflow.com/questions/866102/use-an-alternative-maven-profile-during-test-phase">Use an alternative Maven Profile during test phase</a></li> <li><a href="http://www.google.com/search?q=maven+profile++filtering" rel="nofollow noreferrer">maven profile filtering</a> search on Google</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload