Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should the mvnw files be added to the repository?

When creating spring-boot projects by using start.spring.io, some maven wrapper files get included:

  • mvnw
  • mvnw.bat

Should these files be ignored when committing to a git repo?

like image 388
Titulum Avatar asked Nov 11 '17 17:11

Titulum


People also ask

What is the use of MVNW file?

mvnw: it's an executable Unix shell script used in place of a fully installed Maven. mvnw. cmd: it's the Batch version of the above script. mvn: the hidden folder that holds the Maven Wrapper Java library and its properties file.

Can I delete MVNW?

You can safely remove it if (you can reasonably expect that) everyone you work with has it installed.

What is the .MVN folder?

The . mvn directory is a directory where you can put some Maven configuration files. One of these Maven configuration files is the jvm. config file which can be used to configure the Java VM that is used by Maven to build your project.


2 Answers

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.
like image 113
glytching Avatar answered Sep 18 '22 08:09

glytching


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.

like image 39
dunni Avatar answered Sep 17 '22 08:09

dunni