EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Maven Assembly Plugin

Secondary Sidebar
Maven Tutorial
  • Maven Basic and advance
    • What is Maven
    • How to Install Maven
    • Maven Commands
    • Maven GroupId
    • Maven WAR Plugin
    • Maven Build Command
    • Maven Failsafe Plugin
    • Maven Profile
    • IntelliJ Maven
    • Maven Enforcer Plugin
    • Maven Javadoc Plugin
    • Maven WAR Plugin
    • Maven Build Command
    • Maven GroupId
    • Maven Force Update
    • Maven Encrypt Password
    • Maven Environment Variables
    • AssertJ Maven
    • Maven Run Single Test
    • Maven kafka-clients
    • Maven Quickstart Archetype
    • Maven Install Dependencies
    • Maven XMLBeans
    • Maven Local Repository
    • Maven Versions
    • Maven Jar Plugin
    • Maven Assembly Plugin
    • Maven exec plugin
    • Maven Central Repository
    • Maven Surefire
    • Maven Deploy
    • Maven Phases
    • Maven Archetype
    • Maven Skip Test
    • Maven Dependency Scope
    • Maven Shade Plugin
    • Maven Repository Spring
    • Maven Eclipse Plugin
    • Maven Exclude Dependency
    • Maven Life Cycle
    • Maven Repository
    • Maven POM File
    • Maven Plugins
    • What is Maven Plugins
    • Maven Interview Questions
    • Maven Flags
    • Maven Project
    • Maven Settings.XML
Home Software Development Software Development Tutorials Maven Tutorial Maven Assembly Plugin

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.

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.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,064 ratings)

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

This is a guide to Maven Assembly Plugin. Here we discuss the introduction, how it works? advantages and disadvantages. You may also have a look at the following articles to learn more –

  1. Maven Central Repository
  2. Maven Deploy
  3. Maven Surefire
  4. Jetty Maven plugin
Popular Course in this category
Maven Training (4 Courses, 6 Projects)
  4 Online Courses |  6 Hands-on Project |  26+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

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

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

Special Offer - Maven Training (4 Courses, 6 Projects) Learn More