Maven Wrapper vs Gradle Wrapper: Reproducible JVM Builds in CI
These are not rival build tools - they are wrappers that pin Maven or Gradle to an exact version so CI builds match local ones.
The Maven Wrapper (mvnw) and Gradle Wrapper (gradlew) are scripts committed to the repo that download and run a pinned version of Maven or Gradle. They solve the same problem - version reproducibility - for their respective build tools.
| Maven Wrapper (mvnw) | Gradle Wrapper (gradlew) | |
|---|---|---|
| Pins | Maven version | Gradle version |
| Files committed | .mvn/wrapper + mvnw | gradle/wrapper + gradlew |
| CI command | ./mvnw ... | ./gradlew ... |
| Benefit | No preinstalled Maven needed | No preinstalled Gradle needed |
| Maturity | Standard (newer than gradlew) | Long-standing default |
In CI
Use the wrapper for whichever build tool you already use: ./gradlew or ./mvnw runs the exact pinned version from the repo, so CI does not depend on whatever Maven/Gradle is preinstalled on the runner. The Gradle Wrapper has been the de facto standard for years; the Maven Wrapper brings the same guarantee to Maven projects. They are complementary to your build tool choice, not alternatives to each other.
Cache and pin
Commit the wrapper files, run via ./mvnw or ./gradlew in CI, and cache ~/.m2 or ~/.gradle keyed on your build files. The build runs on CI runners; faster managed runners shorten heavy JVM builds on a cache miss.
The verdict
On Maven: use the Maven Wrapper (mvnw); on Gradle: use the Gradle Wrapper (gradlew). They pin the build-tool version for reproducible CI - it is not a Maven-vs-Gradle choice, but a wrapper for whichever you use.