Should the mvnw files be added to the repository? Should the mvnw files be added to the repository? git git

Should the mvnw files be added to the repository?


A mvnw Maven wrapper script allows you to run a Maven command without having Maven installed and present on your PATH. It does by looking for Maven on your PATH and, if not found, it downloads and installs Maven in a default location (your user home directory, IIRC).

They are a convenience but they are not necessarily part of your project, not in the same way as your project code and configuration is. In other words:

  • Any given mnvw file could be used for multiple, unrelated projects
  • A mnvw file will almost certainly not be different from one version of your project to another

On this basis you could make a case for not committing mvnw to your code repository.

However, including a mvnw script in your repo does have these benefits:

  • Allows anyone who clones / checks-out your repo to build your project without having to install Maven first.
  • Ensures that the version of Maven in use is the version with which your project is compatible.

On this basis you could make a case for committing mvnw to your code repository.

So, there are pros and cons on both sides. Just choose the side which best fits the needs of those who will use your repo. Either:

  • Include something in your readme which makes clear that (a) Maven is a prerequisite and (b) which version of Maven is required.

... or:

  • Include a mvnw script.


It depends, if you want to use the Maven wrapper or not. If not, then you can delete those files. If you want to use it, then you have to commit the files in the repository, otherwise it doesn't make sense to use it.