Maven or Gradle
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Which one do you prefer and use ?
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
2 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
That said, I've never really worked with Gradle, I prefer Maven. It's what I started with, and with the right plugins it can do what I want. And with the upcoming Maven 4 several issues should get resolved as well (like running the SonarQube plugin combined with only "initialize" not working properly for multi-module projects).
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Rob Spoor wrote:This could be as dangerous a topic as "emacs vs vi", "Eclipse vs IntelliJ", "Windows vs Linux vs Mac", etc., so I'd like everybody to not start bashing the tool you don't like.
Fully agree
. My two cents about the topic:
After some trial of Gradle I always went back to Maven despite the fact that I am always struggle with reading the XML syntax.
The thing that keeps me with Maven is the Maven lifecycle concept, and of course the strict standard directory layout. This enables to find myself "at home" even with unknown Maven projects after the step to wade throught the XML syntax.
An ideal build tool - for me - would combine above mentioned lifecycle and directory layout with a more human -readable language e.g. YAML but this choice is not given when comparing Maven vs. Gradle.
...
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
On a technical consideration, I might reach for Gradle over Maven if I wanted to manage a project that comprised of modules written in different programming languages. Otherwise, they pretty much serve the same purpose so go with the one you and/or your team are more familiar with.
Since you're choosing your build tool which is an "architecturally significant" decision it would be worth recording it in an Architecture Decision Record so you and your successors know why you chose it.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Carey Brown wrote:Maven comes with Eclipse, one of the most popular Java IDEs.
I'm not sure that's true. Maven support for Eclipse is handled via a plug-in, as as virtually everything in Eclipse, up to and including Java language development support. Eclipse itself is essentially an OSGi framework.
What we call "Eclipse" is available in several different "spins", which are distros with certain plugins pre-installed. Last time I looked, there were two different spins for Java -- one for generic Java and one for Enterprise Java. And a C-language development spin, plus others I forget. There are additional spins from other places than eclipse.org, but we won´t worry about them.
Originally, at least, the Maven plug-in was NOT pre-installed. As to which, if any, current Java spins have it pre-installed, I don´t know. If Gradle support isn´t (yet?) pre-installed, so be it. Gradle is definitely pre-installed in the Android developer kit from IntelliJ.
Regardless, my own personal experience and preference for most Java projects is Maven. Gradle has better support for mixed-language environments (and for example, Android is often Java+Kotlin). But Gradle builds have been much more fragile in my experience. A Maven build tends to be good for the ages.
As far as dependencies go, Gradle pulls from Maven Central just as Maven itself does. And for that matter, Ivy for Ant. That makes like a lot simpler as you don´t have to worry about which build tool matches your dependencies.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Both are solid options, and I don't think you'd regret choosing either of them. Maven is the old guard, and Gradle is the new kid on the block who's grown pretty old. Maven almost always have a plugin for what you need to accomplish. With Gradle, if there isn't one you have the option to code it yourself in the build.gradle script, as it is a Groovy/Kotlin DSL. So writing your custom actions is easier in Gradle, imho. I also like the multi-module project support better, but that might be me not knowing Maven that well. Build pipeline looks clearer on Maven, it is easier to put a task in the correct place. Gradle feels more like the Prolog language, you don't tell when to do it, you imply by when it should have been done.
For tooling, I think both are solid. Every major IDE has support for both, as far as I can see. Every major CI/CD tool supports them.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
But I'm definitely solidly in the Gradle camp.
The way I view it:
Ant (+Ivy):
Nice and easy to understand since it's just executing commands in order. +1
But you need to deal with that awful XML. -1
Gradle:
Steeper learning curve than Ant -1
...but NO XML! And you can even use Groovy/Java if you really need to. +1
Maven:
Steeper learning curve than Ant -1
...and you need to deal with a ton of awful XML. -1
Final score:
Ant 0
Gradle 0
Maven -2
So Maven's the worst of both worlds on those (cherry picked) very high level criteria. Ant's basically dead now, so I defaulted over to a Gradle preference.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Maven and Gradle projects can only produce single products, although by stacking them you can create multi-product results. As I said, Gradle excels in its ability to produce products in a mixed-language project. However, I've had some bad experiences with Gradle breaking when stuff is upgraded, so I remain guarded.
Unlike Gradle, Maven is intended for Java-only projects. It is, however, more stable than Gradle.
As for XML, you don´t even need an IDE to edit XML. Even the vim editor has an XML plugin and Emacs often distributes with the XML mode pre-installed. Yes, XML is ugly and verbose, but it can be automatically validated (although full schema validation isn't an option for a POM or Ant build file).
Then again, though it isn´t as validatable as XML, YAML is my general preferred complex config language. And as a rule, you can swap out an XML file with YAML. In fact, the Spring Framework is a system where either YAML or XML is allowed. It should, in fact be relatively easy to retro-fit even legacy Maven releases to take YAML POMs, should anyone care to do so.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Upgrade craziness is definitely a downside for Gradle, I agree. I just use SDKMAN to grab whatever version I need (and use a Gradle wrapper to bundle the correct version with the project for build reliability). Those Gradle people are seriously bored, like a Google developer, seemingly changing things like trivial syntax for no obvious reason.
Whenever I compare Maven build files to Gradle, Gradle is normally far shorter and easier to read. Especially when you have a lot of dependencies. That XML bloat really adds up.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
One of the things I initially balked at was how Maven wanted you to organize projects in a way it liked. Probably some residue from early-generation IDEs forcing a vendor-specific layout on their projects made me wary.
Since then, however, I've learned to appreciate that given a Maven project, I will know in advance where to find what. And, for that matter, a "mvn clean" and a ZIP will allow me to ship a project to anyone in the world without worrying about how they organize their filesystem. All they have to do is unzip and build.
Gradle, as an extension of Maven concepts also benefits from this approach, of course.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
H Qam wrote:When do we need them and which one is more efficient when working with java.
Which one do you prefer and use ?
Caveat: I have used both, though I am not an expert in either.
Similarities:
Differences:
My recommendations:
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
The XML is fine for a simpler project, and I admit it's not THAT big of a deal in the grand scheme of things. Compared to the grossness of a big Python project or Rust, it's insignificant.
Gradle does lag behind Java versions. But it's not an issue most of the time since it's a good practice for important production stuff to not be so bleeding edge.
Supposedly I think Gradle is faster to build (especially with repeated builds IIRC), but I don't know that for sure. And that only would really matter for a large build anyway.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Basil .Work wrote:For example, I have seen comments saying Gradle can more gracefully handle multi-module projects (sub-projects that produce an artifact) whereas Maven can struggle there.
The Maven team promises that Maven 4 will improve on that a lot.
Lou Hamers wrote:Supposedly I think Gradle is faster to build (especially with repeated builds IIRC), but I don't know that for sure. And that only would really matter for a large build anyway.
mvnd can supposedly help improve that. I haven't used it myself yet, but it looks to be something like Gradle's daemon which means it doesn't have to reload everything from scratch every single time.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
| girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









