Maven Packaging Types

Maven Packaging Types

We explore the different packaging types available in Maven. Maven offers many default packaging types and also provides the flexibility to define a custom one. The packaging type is an important aspect of any Maven project. It specifies the type of artifact the project produces. Generally, a build produces a jar, war, pom, or other executable.

1. Overview

The packaging type is an important aspect of any Maven project. It specifies the type of artifact the project produces. Generally, a build produces a jar, war, pom, or other executable.

Maven offers many default packaging types and also provides the flexibility to define a custom one.

In this tutorial, we'll take a deep dive into Maven packaging types. First, we'll look at the build lifecycles in Maven. Then, we'll discuss each packaging type, what they represent, and their effect on the project's lifecycle. In the end, we'll see how to define a custom packaging type.

2. Default Packaging Types

Maven offers many default packaging types that include a jar, war, ear, pom, rar, ejb, and maven-plugin. Each packaging type follows a build lifecycle that consists of phases. Usually, every phase is a sequence of goals and performs a specific task.

Different packaging types may have a different goal in a particular phase. For example, in the package phase of jar packaging type, maven-jar-plugin_‘s jar goal is executed. Conversely, for a _war project, _maven-war-plugin_‘s war goal is executed in the same phase.

2.1. jar

Java archive – or jar – is one of the most popular packaging types. Projects with this packaging type produce a compressed zip file with the .jar extension. It may include pure Java classes, interfaces, resources, and metadata files.

To begin with, let's look at some of the default goal-to-build-phase bindings for the jar:

  • resources: resources
  • compiler: compile
  • resources: testResources
  • compiler: testCompile
  • surefire: test
  • jar: jar
  • install: install
  • deploy: deploy

Without delay, let's define the packaging type of a jar project:

<packaging>jar</packaging>

If nothing has been specified, Maven assumes the packaging type is a jar.

maven developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

Hire Ruby on Rails Developer | Hire RoR Developer

#1 Ruby on Rails development company. Hire Ruby on rails developer or a team to build secure, scalable and complex web solutions with a quick turnaround time.

Android Application Development|Android App Development Company Dubai

Dev technosys is top android app development company in Dubai delivers unique and ideal android app from highly experienced android app developers in UAE at best price.