The Maven Wrapper (mvnw) allows you to run Maven projects without installing Maven separately, ensuring the correct version is used across all environments. It improves consistency and simplifies project setup for developers.
- No need to install Maven manually
- Ensures same Maven version for all developers
- Supports easy setup and configuration via wrapper scripts (mvnw/mvnw.cmd)
Why Use Maven Wrapper?
- Consistency: It ensures all the developers use the same Maven Version.
- Ease of use: No need to install the Maven on every developer's machine.
- Portability: Makes it easier to setup the CI/CD pipelines as the exact Maven version is specified of the application
Components of Maven Wrapper
- mvnw and mvnw.cmd: These are shell scripts to run the maven commands.
- .mvn/wrapper/maven-wrapper.jar: The java archive that downloads and installs the specified maven version.
- .mvn/wrapper/maven-wrapper.properties: Its configuration file specifying the maven version.
Step by step Implementation of Maven Wrapper
Step 1: Create a Maven Project
Create a Maven project using the following command:
mvn archetype:generate \
-DgroupId=com.example \
-DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
cd my-app
Output:

Step 2: Add the Maven Wrapper to your project
Navigate to the project directory and install the Maven Wrapper using the following command:
mvn -N io.takari:maven:wrapper
Output:

Build Result:

This command generates several files necessary for the Maven Wrapper.

Step 3: Use Maven Wrapper to Run Maven Commands
Instead of mvn clean install, use the wrapper scripts in your application:
./mvnw clean install
This command ensures that the build uses the Maven version specified in maven-wrapper.properties.
Output:

Installation Result:

By using Maven Wrapper, we can avoid issues related to the different Maven versions and make it easier for new developers to get started with the project. This article provides the comprehensive overview of the Maven Wrapper, including how to set it, up, configure the dependencies and plugins and run the Maven commands.