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

Ask A Question

Stats

  • Questions 266k
  • Answers 266k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use SQL Server profiler in SSMS to see… May 13, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Dump the schema using pg_dump. drop the database, recreate it… May 13, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Funny, but it seems that nobody cares about width of… May 13, 2026 at 12:45 pm

Related Questions

Note: This question has been originally posted by Lahiru Gunathilake as an answer to
I've got m2eclipse plugin installed and there's no problem syncing compile time dependencies that
My application needs to know the path to a directory where it can store
I am not being able to run Powermock through maven. I'm the PowerMock Mockito

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.