Packaging and Deployment
About
In a Maven build lifecycle, packaging and deployment plugins are responsible for producing distributable artifacts (like JAR, WAR, or EAR files) and moving them to the appropriate destinations — such as local/remote repositories, servers, or other deployment environments. These plugins play a critical role in transitioning code from build to runtime.
Maven JAR Plugin
Creates a JAR file from compiled .class
files and resources in the target/
directory. This is the default packaging for standard Java applications.
Default Goal
jar:jar
Basic Configuration
Useful Config Options
archive.manifest.mainClass
Sets the entry point class
excludes
Exclude specific files
includes
Include specific files
Maven WAR Plugin
Packages the web application into a WAR file for deployment to a servlet container like Tomcat.
Default Goal
war:war
Basic Configuration
Useful Config Options
failOnMissingWebXml
For servlet 3.0+, disables need for web.xml
webResources
Add custom web assets
packagingExcludes
Exclude specific files from WAR
Maven Assembly Plugin
Creates custom distributions like ZIP, TAR, or executable JARs with dependencies.
Common Goals
single
Creates one packaged archive
Basic Configuration
Descriptor Refs
jar-with-dependencies
project
bin
src
Maven Deploy Plugin
Uploads your artifact (JAR, WAR, etc.) to a remote Maven repository for sharing with others.
Default Goal
deploy:deploy
Basic Configuration
Repository Credentials
Defined in ~/.m2/settings.xml
under <servers>
tag.
Maven Install Plugin
Installs the artifact into your local Maven repository (~/.m2/repository
), so it can be used as a dependency by other local projects.
Default Goal
install:install
Basic Configuration
No special configuration is required unless we're customizing the artifact or installing non-built JARs.
Maven Shade Plugin
Creates an uber/fat JAR by including all dependencies, and allows filtering, renaming, and relocating classes to avoid conflicts.
Common Goal
shade:shade
Basic Configuration
Last updated
Was this helpful?