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:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…