7

I used the Spring Initializr website https://start.spring.io/ to create a spring boot program, and I wanted to delete the mvnw, mvnw.cmd, and .mvnw directory.

Is there any reason to keep these files maven wrapper files around?

I read What is the purpose of mvnw and mvnw.cmd files? and see that if I didn't have maven installed it would download maven and use that downloaded code to compile my java code.

If I delete them does that cause problems for someone else on the team?

I've always deleted them and it's never caused a problem that I'm aware of, but maybe it's because the team members all have maven installed

It seems like mvnw similar to the npx command in Javascript but only for the one mvn command.

Having Java and Maven installed seems (to me) to be a prerequisite to writing Java code, so I'm baffled as to what problem the Spring Team was solving when then decided to add this feature. If anyone knows the use case or reason that this was done, please share it.

Every couple of years I revisit this question and figured I'd ask it and have the answer in SO for future reference.

cellepo
  • 4,001
  • 2
  • 38
  • 57
PatS
  • 8,833
  • 12
  • 57
  • 100
  • 3
    You can safely remove it if (you can reasonably expect that) everyone you work with has it installed. – dan1st Feb 05 '22 at 00:04
  • 1
    The wrapper thing was first introduced to gradle users. Because gradle developers constantly decide to change configuration format. That is why gradle users have to stay with the gradle version they configured. It is useless for maven users. Better keep away from it. – hurelhuyag Mar 15 '23 at 04:17
  • I'm assuming to also delete the `/.mvn` directory (containing maven-wrapper.jar, and maven-wrapper.properties). – cellepo Apr 04 '23 at 02:36
  • fwiw, same wrapper bug when using start.spring.io via `IntelliJ Spring Initializr`. Related: https://youtrack.jetbrains.com/issue/IDEA-246851/Allow-to-disable-Maven-wrapper-support – cellepo Apr 04 '23 at 02:38
  • Yeah looks like also deleting `/.mvn` was fine as well, in addition to the other artifacts questioned by OP. – cellepo Apr 06 '23 at 18:11

1 Answers1

1

Given the comment thread above on the Question itself here by this point.. I'm going to go ahead and throw an initial official Answer out here that:

Yes, those mvnw files can be safely deleted; as well as <project root>/.mvn directory. (of course, assuming that you don't want/need mvnw features)

I have successfully myself tested deleting them all, in a Spring Boot app built with Maven.

cellepo
  • 4,001
  • 2
  • 38
  • 57