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

  • Home
  • SEARCH
  • 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 9222047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:43:21+00:00 2026-06-18T03:43:21+00:00

I develop a webapp using a model-view-controller pattern. The model package represents the core

  • 0

I develop a webapp using a model-view-controller pattern. The model package represents the core API of the application, that could be used independently. The controller and view packages use the model package to produce a webapp.

Question:
I’d like to be able to build a JAR of only the model package, and a WAR of the three packages. And I’d like to keep the three packages in a same project. The webapp WAR would include supplementary libraries as compared to the standalone JAR.
How could I achieve this with Maven? Would there be a solution using for instance two separate pom.xml files? (because as far as I know, you cannot choose two packaging options in the pom.xml)

(I’ve seen this question, but I really want my three packages to be part of a same project, and be part of the same directory.)

Also, my project uses a classical webapp structure (simplified here):

my-app
-- pom.xml
-- src
----- main/
-------- java/
----------- model/
----------- view/
----------- controller/
-------- webapp/
---------- WEB-INF/
-------------classes/

Could I manage to generate the JAR in the classical target/ directory, and the webapp in the classical src/main/webapp/ directory? (and, as asked, including different libraries)

Thanks for your help.

  • 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-06-18T03:43:22+00:00Added an answer on June 18, 2026 at 3:43 am

    Take a look at Maven Assembly Plugin.

    With it you can have as many different Assembly Descriptors as you need, each one customized with its own packaging scheme, filesets and dependencies.


    Here is a sample plugin configuration for your pom.xml:

    <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptors>
                   <descriptor>src/main/assembly/model.xml</descriptor>
                </descriptors>
            </configuration>
         </plugin>
      </plugins>
    </build>
    

    And a sample assembly descriptor for the model jar (src/main/assembly/model.xml)

    <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>model</id>
      <formats>
        <format>jar</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <fileSets>
        <fileSet>
          <directory>${project.build.outputDirectory}/model</directory>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>**/*</include>
          </includes>
        </fileSet>
      </fileSets>
    </assembly>
    

    Running mvn clean package assembly:single will generate both the standard my-app.war file from your project pom.xml and a my-app-model.jar in the target package.

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

Sidebar

Related Questions

I am using IIS to develop some web applications. I used to believe that
I am using Ruby on Rails to develop a webapp. I want it so
If you'd like to develop a WebApp which you know that is going to
here is the skeleton script that i am using: #!/usr/bin/env perl =head1 NAME webapp-1
I'm using tomcat and Spring 3.1 to develop a Maven webapp. The data source
Currently we develop our webapps using webspeed that comes with the progress development tools.
I'm develop web app for bada platform using badaWAC api. What are the ways
I try to develop a simple webapp using GWT + hibernate4 + Apache Tomcat.
I'm using Turbogears2 and SQLAlchemy to develop a webapp. I have two mapped tables
I am using jsp to develop a web application...using tomcat server... I am facing

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.