Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 483069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:09:35+00:00 2026-05-13T01:09:35+00:00

When doing a mvn install I want to end up with 2 WAR files

  • 0

When doing a mvn install I want to end up with 2 WAR files in my target directory. One will contain the production web.xml and the other will contain the test/uat web.xml.

I’ve tried this:

<build>
    <finalName>cas-server</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <webXml>src/main/config/prod/web.xml</webXml>
                <warName>cas-prod</warName>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <webXml>src/main/config/test/web.xml</webXml>
                <warName>cas-test</warName>
            </configuration>
        </plugin>
    </plugins>
</build>

But I only end up with the test WAR.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:09:35+00:00Added an answer on May 13, 2026 at 1:09 am

    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.

    If your web.xml 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:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.1-beta-1</version>
      <configuration>
        <webXml>src/main/config/${env}/web.xml</webXml>
        <warName>cas-test</warName>
      </configuration>
    </plugin>
    

    And set the env property in two profiles to pick up the right web.xml at build time.

    <profiles>
      <profile>
        <id>uat</id>
        <properties>
          <env>test</env>
        </properties>
      </profile>
      <profile>
        <id>prod</id>
        <properties>
          <env>prod</env>
        </properties>
      </profile>
    </profiles>
    

    If your web.xml 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:

    <profiles>
      <profile>
        <id>env-uat</id>
        <activation>
          <property>
            <name>env</name>
            <value>uat</value>
          </property>
        </activation>
        <properties>
          <key1>uat_value_key_1</key1>
          <keyN>uat_value_key_n</keyN>
        </properties>
      </profile>
      <profile>
        <id>env-prod</id>
        <activation>
          <property>
            <name>env</name>
            <value>prod</value>
          </property>
        </activation>  
        <properties>
          <key1>prod_value_key_1</key1>
          <keyN>prod_value_key_n</keyN>
        </properties>
      </profile>
    </profiles>
    

    Then activate one profile or the other by passing the env property on the command line, e.g.:

    mvn -Denv=uat package
    

    Another option would be to put the values into specific filters and pick up the right one at build time (like in this post).

    There are really many options but as I said, I don’t think you can do this without runngin the build twice.

    More resources on profiles/filtering:

    • Maven Book: Chapter 11. Build Profiles
    • Maven Book: Chapter 15.3. Resource Filtering
    • Introduction to Build Profiles
    • Use an alternative Maven Profile during test phase
    • maven profile filtering search on Google
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried doing a mvn dependency:tree and I get a tree of dependencies. My
doing a simple login for my website, which will hopefully keep the user logged
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I've been seeing odd behaviour from my Maven 2.2.1 installation whilst doing war installs.
Is there a way to tell maven (when doing mvn package , mvn site
I want to checkout sonar, so I added the following snippet to my pom.xml
When I run my build using maven 2 mvn clean install my tests are
I need to deploy a production version of a web application. So far, I've
In one of my Maven projects, dependency resolution will succeed once, then fail for
I am mavenizing an ant project. One module includes XSD files that are used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.