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 7642305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:09:20+00:00 2026-05-31T09:09:20+00:00

I’m working on trying to have my project automatically build two different versions of

  • 0

I’m working on trying to have my project automatically build two different versions of a project. What I have done is I have added two different plug-in executions as follows

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>exploded</goal>
                    </goals>
                </execution>                
            </executions>
            <configuration>
                <resources>
                    <resource>
                    <directory>src/main/resources/first</directory>
                    </resource>
               </resources>
                <webappDirectory>${webappDirectory}</webappDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>war</goal>
                    </goals>
                </execution>                
            </executions>
            <configuration>
                <resources>
                    <resource>
                        <directory>src/main/resources/second</directory>
                    </resource>
               </resources>
                <webappDirectory>${project.build.directory}/deployment</webappDirectory>
            </configuration>
        </plugin>

It builds both webappDirectories and it created the war file as expected, but the resources doesn’t get included correctly (it seems to ignore the resource definitions above).

I am guessing its because I am doing this in the wrong phase, at what phase do I need to override the default resources directory?

(please notice, I do not wish to have two different profiles, I want to have both done at once)

  • 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-31T09:09:22+00:00Added an answer on May 31, 2026 at 9:09 am

    I have wrote an blog entry exactly about that problem but the essence is about to have the maven project (in your case the war module) with the following structure:

    .
    |-- pom.xml
    `-- src
        |-- main
        |   |-- java
        |   |-- resources
        |   |-- environment
        |   |   |-- test
        |   |   |   `-- database.properties
        |   |   |-- qa
        |   |   |   `-- database.properties
        |   |   `-- production
        |   |       `-- database.properties
        |   `-- webapp
    

    The most important thing is to create the different configuration via the maven-assembly-plugin with a configuration like this:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>test</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>${project.basedir}/src/main/assembly/test.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
          <execution>
            <id>qa</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>${project.basedir}/src/main/assembly/qa.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
          <execution>
            <id>production</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>${project.basedir}/src/main/assembly/production.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    

    what you also need are assembly descriptors like the following:

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    
      <id>test</id>
      <formats>
        <format>war</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <dependencySets>
        <dependencySet>
          <unpack>true</unpack>
          <useProjectArtifact>true</useProjectArtifact>
        </dependencySet>
      </dependencySets>
      <fileSets>
        <fileSet>
          <outputDirectory>WEB-INF</outputDirectory>
          <directory>${basedir}/src/main/environment/test/</directory>
          <includes>
            <include>**</include>
          </includes>
        </fileSet>
      </fileSets>
    </assembly>
    

    Of course you have to name them accordingly and obviously you have to change the directory within the descriptor as well. Based on that it is now possible to create multiple artifacts (in your case war files) with different configurations during the package cycle. So you simply call your project build via:

      mvn clean package
    

    Finally i recommend not to use the src/main/resources folder, cause that folder should be used for production information which does not change for the different configuration. Furthermore the src/test/resources will be used for the test resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.