The easiest way to integrate Maven into your project!

Overview

Maven Wrapper

Ongoing Migration to Apache Maven

The project codebase has been accepted to be included in the upstream Apache Maven project itself. Currently the plan is to release the wrapper as a feature of the upcoming Maven 3.7.0 release. For this purpose the following resources are available:

We encourage any users and contributors to work with us within the Apache Maven project on any further changes.

This project is essentially frozen now.

Legacy Documentation

The Maven Wrapper is an easy way to ensure a user of your Maven build has everything necessary to run your Maven build.

Why might this be necessary? Maven to date has been very stable for users, is available on most systems or is easy to procure: but with many of the recent changes in Maven it will be easier for users to have a fully encapsulated build setup provided by the project. With the Maven Wrapper this is very easy to do and it's a great idea borrowed from Gradle.

The easiest way to setup the Maven Wrapper for your project is to use the Takari Maven Plugin with its provided wrapper goal. To add or update all the necessary Maven Wrapper files to your project execute the following command:

mvn -N io.takari:maven:0.7.7:wrapper

Note: The default usage should be mvn -N io.takari:maven:wrapper but for some users this seem to result in usage of an old version of the wrapper and therefore installation of older Maven defaults and so on.

Normally you instruct users to install a specific version of Apache Maven, put it on the PATH and then run the mvn command like the following:

mvn clean install

But now, with a Maven Wrapper setup, you can instruct users to run wrapper scripts:

./mvnw clean install

or on Windows

mvnw.cmd clean install

A normal Maven build will be executed with the one important change that if the user doesn't have the necessary version of Maven specified in .mvn/wrapper/maven-wrapper.properties it will be downloaded for the user first, installed and then used.

Subsequent uses of mvn/mvnw.cmd use the previously downloaded, specific version as needed.

Supported Systems

The wrapper should work on various operating systems including

  • Linux (numerous versions, tested on Ubuntu and CentOS)
  • OSX / macOS
  • Windows (various newer versions)
  • Solaris (10 and 11)

For all those *nix operating systems, various shells should work including

  • sh
  • bash
  • dash
  • zsh

In terms of Apache Maven versions itself, the wrapper should work with any Maven 3.x version and it defaults to the latest release - currently 3.6.3. We do NOT plan to support the deprecated, EOL'ed Maven 2.x.

The maven-wrapper itself is compiled to work with Java 5. The Takari Maven Plugin for installation however uses Java 7. Once the wrapper is installed with the plugin you should be able to use the wrapper on the project with Java 5 and up. This is however not really tested by the committers.

Changes

Please check out the changelog for more information about our releases.

Verbose Mode

The wrapper supports a verbose mode in which it outputs further information. It is activated by setting the MVNW_VERBOSE environment variable to true.

By default it is off.

Usage without Binary JAR

By default, the Maven Wrapper JAR archive is added to the using project as small binary file .mvn/wrapper/maven-wrapper.jar. It is used to bootstrap the download and invocation of Maven from the wrapper shell scripts.

If your project is not allowed to contain binary files like this, you can configure your version control system to exclude checkin/commit of the wrapper jar.

If the JAR is not found to be available by the scripts they will attempt to download the file from the URL specified in .mvn/wrapper/maven-wrapper.properties under wrapperUrl and put it in place. The download is attempted via curl, wget and, as last resort, by compiling the ./mvn/wrapper/MavenWrapperDownloader.java file and executing the resulting class.

If your Maven repository is password protected you can specify your username via the environment variable MVNW_USERNAME and the password via the environment variable MVNW_PASSWORD.

Using a Different Version of Maven

To switch the version of Maven used to build a project you can initialize it using:

mvn -N io.takari:maven:0.7.7:wrapper -Dmaven=3.5.4

which works for any version except snapshots. Once you have a wrapper you can change its version by setting the distributionUrl in .mvn/wrapper/maven-wrapper.properties, e.g.

distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

Using Basic Authentication for Distribution Download

To download Maven from a location that requires Basic Authentication you have 2 options:

  1. Set the environment variables MVNW_USERNAME and MVNW_PASSWORD

    or

  2. add user and password to the distributionUrl like that: distributionUrl=https://username:password@<yourserver>/maven2/org/apache/maven/apache-maven/3.2.1/apache-maven-3.2.1-bin.zip

Specifying Maven Distribution Base Path

This is a feature of Maven itself and the wrapper just happens to take it into account. Simply set MAVEN_USER_HOME to the desired path and the wrapper uses it as the base of the Maven distro installation.

See https://www.lewuathe.com/maven-wrapper-home.html and https://github.com/takari/maven-wrapper/issues/17

Using a Maven Repository Manager

When using an internal Maven repository manager you have two options:

  1. Just set the correct URL to wrapper jar and Maven distro in maven-wrapper.properties in your project
  2. Leave the default URL in the project pointing to Maven Central and set the environment variable MVNW_REPOURL to your repo manager URL such as https://repo.example.com/central-repo-proxy.

If MVNW_REPOURL is set during the wrapper installation with the takari-maven-plugin, the URL is used in the maven-wrapper.properties file.

If not set, but your mirror URL in your settings.xml is configured, it will be used.

Developing and Releasing

To test Maven wrapper usage:

  • ensure you are building on a Unix filesystem with correct mounting for executable flag setting
  • build the maven-wrapper as snapshot version
  • update version in takari-maven-plugin
  • build takari-maven-plugin
  • use on test project with takari-maven-plugin version
mvn -N -X io.takari:maven:0.7.7-SNAPSHOT:wrapper

For release

  • make sure version in mvnw files, MavenWrapperDownloader.java and config files and pom files is new upcoming release
  • cut maven release with usual release plugin usage
  • update maven plugin to release version
  • release it as well

Updating Maven version:

  • update URL in maven-wrapper/.mvn/wrapper/maven-wrapper.properties
  • update URL in MavenWrapperMain
  • updated DEFAULT_MAVEN_VER parameter in takari-maven-plugin WrapperMojo class
Comments
  • What about a default settings.xml?

    What about a default settings.xml?

    In a corporate environment, it would be nice to have a default settings.xml. It could be put at .mvn/wrapper/settings.xml and the mvnw script would install it if the user doesn't have a settings.xml. Thoughts?

    opened by Randgalt 26
  • Use of bashisms make this script fail in minimal /bin/sh implementations like dash

    Use of bashisms make this script fail in minimal /bin/sh implementations like dash

    In mvnw, the use of $(pwd) to invoke commands instead of `pwd` to do it is a bashism. This can be fixed either by using the sh-compatible backtick version or specifying /bin/bash in the shebang. Some GNU/Linux distributions ship with minimal sh-compatible shells as the default /bin/sh instead of bash. Debian switched to dash a while back, and I think Ubuntu followed that as well but I haven't checked.

    opened by jvz 16
  • place 'maven-wrapper.jar' in ${user.home}/.m2/wrapper

    place 'maven-wrapper.jar' in ${user.home}/.m2/wrapper

    Hi, now the layout of maven-wrapper is :

    ${basedir}/mvnw
    ${basedir}/mvnw.cmd
    ${basedir}/.mvn/wrapper/maven-wrapper.jar
    ${basedir}/.mvn/wrapper/maven-wrapper.properties
    ${basedir}/.mvn/wrapper/MavenWrapperDownloader.java
    
    ${user.home}/.m2/wrapper/dist/xxx/apache-maven-<ver>-bin/
    

    The downloadable artifact maven-wrapper.jar is placed in the project dir. Can we cache this jar in user conf dir at ${user.home}/.m2/wrapper/maven-wrapper-<ver>.jar or ${user.home}/.m2/wrapper/launcher/maven-wrapper-<ver>.jar? Then there is no generated files of the building project in non-${basedir}/target dir.

    opened by gzm55 15
  • boot behavior of the script 'mvnw' is out of sync with the original 'mvn'

    boot behavior of the script 'mvnw' is out of sync with the original 'mvn'

    Hi, I think the entry scripts mvnw{,.cmd} take much codes of the original mvn{,.cmd} and use own wrapper launcher to replace plexus launcher in order to do some provision actions. So the behavior of mvnw + wrapper_launcher should be almost the same as mvn + plexus_launcher.

    From maven 3.5.0, M2_HOME is removed, and the property library.jansi.path is set, but our mvnw is not followed up. So we need to sync mvnw to the default maven dist (3.5.0+).

    Here is two solutions:

    • a) manually update codes of mvnw and wrapper launcher to mimic the boot progress of our selected maven version (3.5.2 now), and each time we update the default maven, we should do this again.
    • b) do little refactor, wrapper only assemble the dist path and optionally downloads/install the maven dist, then exec into the original mvn

    Personally I prefer b), the boot behavior is always sync to selected maven version by user and wrapper project is more simpler; the only cons may be that on some machine without md5sum command, we have to execute an additional java process to assemble the maven home.

    opened by gzm55 14
  • download maven-wrapper.jar within the script

    download maven-wrapper.jar within the script

    Wouldn't be possible to download the jar with curl if the jar is not available?

    This could be a patch on the script.

    if [ ! -f $MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar ]; then
        curl -o $MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar http://central.maven.org/maven2/io/takari/maven-wrapper/0.1.4/maven-wrapper-0.1.4.jar
    fi
    

    the same would have to be done on the .cmd

    Someone just submitted a pr on Apache artemis using this wrapper, and the first question that came to mind was the wrapper.jar that would have to be commited as part of the source code.

    opened by clebertsuconic 14
  • Extend the scripts to auto-download the maven-wrapper.jar from maven central

    Extend the scripts to auto-download the maven-wrapper.jar from maven central

    I extended the scripts to allow usage of maven-wrapper without requiring the jar to be checked in with the rest of the sources. If the jar is found (because it is checked in or if it had been downloaded peviously) this is used, if not several options are tried out depending on the platform:

    • Windows:

      • powershel is used to download
    • Linux/Mac:

      • curl
      • wget
      • if both are not available a java class is compiled and executed to do the download.

    I didn't add the java option to the windows script for now as far as I know the powershel option should be available on all windows systems.

    opened by chrisdutz 13
  • Can I use exist settingsXML? 我能使用已有的settings.xml吗?

    Can I use exist settingsXML? 我能使用已有的settings.xml吗?

    I had a maven settings.xml already, 我已经有了一个settings的配置文件, it include my own nexus server,and other setting like plugin,profile, 包含了自建的nexus私有仓,以及像插件和profile, How can I use mvnw with this setting file for the default? 我如何在mvnw中默认就使用这个配置文件?

    opened by ElanZh 12
  • Be defensive about creating directories for files

    Be defensive about creating directories for files

    Maven 3.4 snapshots are now being published with invalid zip files, where the entries are listed before their parent. So the logic in the Installer is faulty: you have to mkdirs() on all entries to be sure that the directory exists before you write the file.

    opened by dsyer 12
  • mvnw fails to download from nexus oss

    mvnw fails to download from nexus oss

    We are hosting an nexus oss. Configuring the settings.xml for maven to get everything from there makes the wrapper installation fail. Initially i was thinking this is an issue on nexus oss side, but as you can see here https://issues.sonatype.org/browse/NEXUS-20863 it does not look like that. Mvnw tries to download the maven-wrapper-0.5.5.tar.gz without authentication, which is not allowed on our repository manager. How can we configure the settings.xml that mvnw uses the credentials from the settings.xml?

    opened by benbrummer 10
  • The wrapper writes debug info to stdout when downloading

    The wrapper writes debug info to stdout when downloading

    Ran into an issue where the wrapper pollutes stdout.

    APPLICATION_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec); echo "$APPLICATION_VERSION"
    
    0.0.3-SNAPSHOT
    
    rm -r ~/.m2/wrapper/dists/
    APPLICATION_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec); echo "$APPLICATION_VERSION"
    
    Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.2.5/apache-maven-3.2.5-bin.zip
    ...................................................................................................................................................................................................................................................................................................................................................................................................................
    0.0.3-SNAPSHOT
    

    Please consider not writing this info to stdout, or write it to stderr.

    opened by eiden 10
  • use @REM instead of #

    use @REM instead of #

    using # in .cmd files as comment issues the following error: Der Befehl "#" ist entweder falsch geschrieben oder konnte nicht gefunden werden. aka command not found

    opened by dodgex 10
  • Fix issue reading maven-wrapper.properties

    Fix issue reading maven-wrapper.properties

    MavenWrapperDownloader.java has issues with the generation of the path for the file maven-wrapper.properties. Due that the file is not readed, an alternative url in wrapperUrl is ignored.

    For a proof of concept, please see https://git.sr.ht/~jumapico/maven-wrapper-reproduce-bug.

    opened by jumapico 0
  • Fix bug in Windows Maven Wrapper script

    Fix bug in Windows Maven Wrapper script

    (I am aware that this project is frozen. However, this version of maven wrapper is still very common, including in new projects generated by Spring Initializr. Therefore, I request this be kept open as documentation for others on how to resolve this issue.)

    The mvnw.cmd script that has a bug in the functionality that should loop over the .mvn/wrapper/maven-wrapper.properties, which causes the properties to not take effect. This is especially problematic in development environments that require the use of a maven repository other than Maven Central.

    To fix the issue, in mvnw.cmd edit the FOR loop at lines 125-127 to add the usebackq option

    FOR /F "tokens=1,2 delims== usebackq" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
        IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
    )
    

    Explanation: The double quotes around the filename causes the FOR command to treat it as string. But adding the usebackq option changes the FOR command to instead treat the double-quoted string as a filename set (reference)

    opened by baincd 1
Owner
null
Support alternative markup for Apache Maven POM files

Overview Polyglot for Maven is a set of extensions for Maven 3.3.1+ that allows the POM model to be written in dialects other than XML. Several of the

null 828 Dec 17, 2022
A lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your Java awesome app.

PipelinR PipelinR is a lightweight command processing pipeline ❍ ⇢ ❍ ⇢ ❍ for your awesome Java app. PipelinR has been battle-proven on production, as

Eduards Sizovs 288 Jan 8, 2023
An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch!

OpenBlocks An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch! What is OpenBlocks?

OpenBlocks 30 Dec 16, 2022
Accessible GUI-driven robot programming for your product

Accessible GUI-driven robot programming for your product Description Roblocks is an accessible Graphical Programming Tool which enables basic robot pr

Dustin 5 Sep 19, 2022
From Java To Kotlin - Your Cheat Sheet For Java To Kotlin

From Java To Kotlin From Java To Kotlin - Your Cheat Sheet For Java To Kotlin 中文支持 Português Español Print to Console Java System.out.print("Amit Shek

MindOrks 5.8k Dec 29, 2022
Develop your GitHub Actions in Java with Quarkus

Quarkus GitHub Action Develop your GitHub Actions in Java with Quarkus Interested in GitHub Apps? Have a look at the Quarkus GitHub App extension. Qua

Quarkiverse Hub 7 Jan 6, 2023
a little project that will help you get in jail

Heftgen [ˈhɛftçən] ausgesprochen: Heftchen Development Install this npm module globally (https://www.npmjs.com/package/git-conventional-commits) Enabl

null 5 Jun 26, 2021
YDI_B It is a project to download videos from YouTube

YDI-B in this project will be Application based YouTube url extractor . downloader youtube video and audio from url Gradle To always build from the la

ismail belgacem 6 Jun 27, 2022
This is a basic Java project focused on applying object-oriented design in a real world application

Email-Administration-System-in-Java This is a basic Java project focused on applying object-oriented design in a real world application. Email Adminis

Muhammad Asad 5 Feb 4, 2022
This project is a specialized fork of Checkstyle to support older runtime environments of users who can't upgrade

checkstyle-backport-jre8 The latest release version can be found at GitHub releases or at Maven repo. This project is a specialized fork of Checkstyle

null 3 Apr 21, 2022
The project was created using the API of the Spotify application.

Spotify API The project was created using the API of the Spotify application.

Atakan Koçyiğit 3 Jan 27, 2022
An open-source component of TabLight project "Base-API"

DataAddons is a library (or framework?) created for Minecraft providing comfortable abstractions making additions over already existing data, generally, it is anti-pattern ans YOU SHOULDN'T USE IT in normal programms.

XXR 3 Mar 8, 2022
This open source project allows you to easily integrate Camunda's External Task Clients into Micronaut projects: simply add a dependency in your Micronaut project

micronaut-camunda-external-client This open source project allows you to easily integrate Camunda 's External Task Clients into Micronaut projects. Mi

Novatec Consulting GmbH 19 Dec 18, 2022
To quickly integrate your applications into the EdgeGallery platform, we provide the toolchain project to help developers quickly modify code and migrate applications to the platform.

Toolchain 工具链 工具链是MEC Developer开发者平台中的一个重要特性,当x86平台的App想要上车ARM平台时,底层的代码不可避免的需要进行修改或重写。 App提供者可以通过MEC Developer开发者平台中集成的工具链进行源代码分析,定位需要修改的源代码并根据指导意见进行修

EdgeGallery 19 Jan 7, 2022
Toloka has a powerful open API, it allows you to integrate an on-demand workforce directly into your processes, and to build scalable and fully automated human-in-the-loop ML pipelines.

Toloka Java SDK Documentation Website | API Documentation | Platform Designed by engineers for engineers, Toloka lets you integrate an on-demand workf

Toloka 10 Apr 27, 2022
An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or to turn an existing project into a devops project using open source software (Git, Docker, Jenkins..)

DevOpsify Description An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or t

obaydah bouifadene 14 Nov 8, 2022
JAP is an open source authentication middleware, it is highly decoupled from business code and has good modularity and flexiblity. Developers could integrate JAP into web applications effortlessly.

?? JAP 是什么? JAP 是一款开源的登录中间件,基于模块化设计,并且与业务高度解耦,使用起来非常灵活,开发者可以毫不费力地将 JAP 集

Fujie 140 Dec 1, 2022
UniFi Proxy makes it possible to integrate third-party hardware into UniFi Protect

UniFi Proxy UniFi Proxy makes it possible to integrate third-party hardware into UniFi Protect. For testing purposes only, it is recommended to purcha

Jan Heil 8 Dec 27, 2022
Simple way of causing a bsod using the native api implemented into a 1.12.2 Forge mod

Simple-BSOD-Mod Simple way of causing a bsod using the native api implemented into a 1.12.2 Forge mod. Dowload It HERE To make your own you can go to

INZO_Technologies 5 Dec 28, 2022