EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials Maven Tutorial Maven Assembly Plugin
 

Maven Assembly Plugin

Updated April 17, 2023

Maven Assembly Plugin

 

 

Introduction to Maven Assembly Plugin

Maven assembly plugin is used to combine all project output into a single archive distributed file, this file already contains the documentation, modules, dependencies and other files related to the project. We can easily build the distribution of our project, using the prefabricated assembly descriptors we can build our project easily. The maven assembly descriptors is handling the many operations related to project like project artefact, packaging and document generation in a single file. Our project is providing its own descriptor and we assume that it has a high level of control on dependencies.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

What is Maven Assembly Plugin?

It is nothing but the group of files which contains the dependencies, project directory and other files which was clubbed in archive format. The maven project is nothing but the single JAR file which was contains swing application and console application.

Below is the format which was used to create distribution of project.

  • war: It will create project in war file format.
  • dir: It will create the project directory format.
  • jar: It will create project in jar file format.
  • tar.xz or txz: It will create project in tar.xz file format.
  • Zip: It will create project in zip file format.
  • tar: It will create project in tar file format.
  • tar.gz or tgz: It will create project in tar.gz file format.
  • tar.snappy: It will create project in tar.snappy file format.
  • tar.bz2 or tbz2: It will create project in tar.bz2 file format.
  • Archive manager format.

For using assembly plugin in maven project we need to choose the write assembly descriptor. In assembly descriptor will play very important role. After choosing the write assembly descriptor we need to configure the assembly plugin i.e. pom.xml. After configuring assembly plugin we need to run the assembly single mvn in our project. We can also generate our own assembly for our project.

Below are the apache version available for the general use.

  • Version 2.0.x
  • Version 2.1.x
  • Version 2.2.x
  • Version 2.3.x
  • Version 2.4.x
  • Version 2.5.x
  • Version 2.6.x
  • Version 3.0.x
  • Version 3.1.x
  • Version 3.2.x
  • Version 3.3.x

In below example we can see that how we can configure to the existing application. In below example we are configuring the plugin to the existing assembly maven project.

For configuring we need to follow below steps.

1. Open the existing maven project.

  • To configure the first step is to open the existing maven project.

In below example we are opening the assembly project.

File -> open project from file system -> select the project

Maven Assembly Plugin 1

2. After opening the maven project, we need to open the pom.xml file and need to add the assembly plugin into it.

Code:

<plugin> --- start of assembly plugin section.
<artifactId> /* start of artifactid section.
maven-assembly-plugin /* name of plugin */ </artifactId> -- end of artifactid section.
<configuration> -- start of assembly configuration section.
<descriptorRefs> -- start of descriptorRefs section.
<descriptorRef>j/* start of second descriptorRefs. */ jar-with-dependencies /* descriptorRefs name */ </descriptorRef> -- end of descriptorRefs section.
</descriptorRefs> -- end of second descriptorRefs section.
<archive> -- start of archive section
<manifest> -- Start of manifest section
<mainClass> /* start of main class */ com.example.AssemblyApplication /* name of main class */ </mainClass> -- end of main class.
</manifest> -- end of manifest section
</archive> -- end of archive section
</configuration> -- end of configuration section.
<executions> -- start of executions section.
<execution> -- start of second execution section.
<id>make-assembly</id> -- Set the id name of maven assembly section.
<phase>package</phase> -- select the package.
<goals> -- start of goals section.
<goal>single</goal>
</goals> -- end of goal section.
</execution> -- end of execution section.
</executions> -- end of execution section.
</plugin> -- End of assembly plugin.

Output:

we need to open the pom.xml file

3. After adding the assembly plugin code build the assembly plugin, after building the assembly plugin run the application.

Maven Assembly Plugin 3

run the application

  • The main goal of assembly in java application is single. The single goal is used to create all assemblies.
  • We need to specify id at the time of creating assembly plugin. ID is very important section.

Advantages and Disadvantages of Maven Assembly Plugin

Given below are the advantages and disadvantages mentioned:

Advantages:

  • We are adding maven assembly plugin in pom.xml so it will adding all the dependency automatically which was required for the project.
  • We can easily build our project into jar, war and zip file after adding maven assembly plugin in our project.
  • Using maven assembly plugin in maven project we can easily convert our project into different environment.
  • After converting maven project into different environment we have no need to handle the dependency like builds, injection and processing.
  • After implementing it we can easily run our project after building the same.
  • It is easy to add another dependency plugin to our project.

Disadvantages:

  • We need to install maven to run the plugin of maven assembly, without installing of maven we cannot run the maven plugin.
  • To use the plugin we need to add the code into the pom.xml file.
  • We cannot run our application without adding the code into the pom.xml file.
  • To run the maven application using assembly plugin first we need to build the assembly plugin.
  • Without building the assembly plugin we cannot use in our project.

Conclusion

It is used to combine all project output into single distributed file. We can convert our project output in tar, zip and war file format using it. It is very useful and important to combine all project output in single file.

Recommended Articles

We hope that this EDUCBA information on “Maven Assembly Plugin” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. Maven Central Repository
  2. Maven Deploy
  3. Maven Surefire
  4. Jetty Maven plugin

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW