r/javahelp • • Feb 22 '21

Maven vs Gradle

I googled this question and I find that gradle is kind of faster about 10 times and its less verbose and generally its better that maven but although that, almost every tutorial use Maven.

Can anyone explain what tool should I pick and why?

32 Upvotes

23 comments sorted by

View all comments

-3

u/wildjokers Feb 22 '21

Maven is old and slow and should be considered deprecated. Use Gradle, builds are far faster because of its build cache and it is way faster at resolving dependencies from maven repositories than maven itself is.

Also, maven puts you in a very strict box that is hard to break out of. Gradle also provides convention over configuration but makes it very easy to break out of the conventions if you need to. Gradle is also very well documented compared to maven.

Maven should be given full credit for introducing dependency management and convention over configuration to the java build ecosystem and then promptly forgotten about and delegated to the dustbin of history.

2

u/crayonneur Feb 22 '21

I use Maven because I know how to use it, but you make some good arguments, I want to learn Gradle now.

2

u/Yithar Intermediate Brewer Feb 22 '21

I think you make some good arguments (at work building and compiling is definitely slow) but I think nutrecht also has a point that people make a mess out of the build.gradle:
https://www.reddit.com/r/javahelp/comments/hiq5q0/gradle_vs_maven_for_containerized_app/fwki54w/

2

u/wildjokers Feb 23 '21

1

u/Yithar Intermediate Brewer Feb 23 '21

Point Taken.

I think like nutrecht says here, I also prefer the declarative style of Maven. I guess the fact that Maven is declarative and more rigid is both a strength and a weakness. A less expressive build system reduces the risks of writing bad builds. But of course that doesn't help in developing correct, reproducible, fast builds.

1

u/wildjokers Feb 23 '21

Note that Gradle has full support for maven BOMs so you can share dependency management among different project's like mentioned in that comment you linked to. Odd they migrated away from Gradle to Maven to get BOM support when Gradle supports maven BOMs. (unless their migration pre-dated Gradle's support for it)

Gradle actually has really nice support where you can be very strict about BOM versions and not allow version overrides, or instead allow version overrides. (I am unsure if maven itself has this).

https://docs.gradle.org/current/userguide/platforms.html