In this article I will tell about my experiences with Gradle and Maven. I wasn't planning to compare these tools deliberately, but a recent situation caused me to do it and I felt like sharing my conclusions.
It is highly likely that you know the game Minecraft. I used to play that game a lot. I liked it so much that when I discovered that there are modding tools for it, I wanted to create my content for it. So I started learning. I had none experience in programming, except a couple of courses in my school. I started to learn Java, because Minecraft is written in it. It was very difficult for someone with zero experience in real world programming. Way back then (beta times) Minecraft modding tools used some Python scripts for building mods. The main and most popular modding kit is called Forge. It was created by some developers to uniform the modding process. I was learning Java and Forge, and was working on my first mods in parallel. After some time, I had managed to make and release some of them.
This went for a while. And then the team behind Forge decided to choose Gradle as a build tool for the mods. This forced me to start learning it. Another painful process. After learning necessary things I was thankful for their decision. Yes, using a build tool is more convenient than setting up development environment and stuff manually and using an array of scripts.
Gradle scripts are written in DSL, which extends from Groovy. Groovy is a dynamically typed JVM programming language. Although it seems attractive at first, code written in it can easily become a complex and unmanageable mess, due to various features, syntactic sugar and language "improvements" that are piled up onto each other. No wonder it's not fully supported in IDEs nowadays. And Gradle scripts were written exclusively in its DSL language at that time. I learned Groovy in the process, nevertheless, but that knowledge didn't benefit me much. Probably, that's why Gradle authors implemented Kotlin scripts later.
I invested a lot of time into reading Gradle documentation. And a lot of effort to apply gained knowledge to my programming work. I started writing usual applications with Gradle. I can say that Gradle authors seem to think it's fine to introduce new features and syntax in every version and deprecate previous ones. Their documentation is often lacking in certain topics. Which must not be the case for a build tool used by thousands of developers. Let's examine the points of their comparison with Maven (on May of 2020):
And that's all. Not really attractive if you carefully analyze them.
I finally decided to learn Maven while working on a serious Java project. I couldn't figure out how set up Gradle's tooling API and decided to drop it. I restarted the project, without any build tool and worked on it for some time. But working on it without a build tool was inconvenient when you switch computers or operating systems, so I decided to try Maven out. I used my IDE to convert my generic project into a Maven one; then I found necessary documentation relatively quickly, and applied it to my project. I had to search some info in the internet, but it was also fast. Fortunately, Maven is conservative when it comes to features and build files - no breaking changes are expected in new versions. Your build script can expand, but you don't need to change what's already present. The script might be bigger than Gradle's, but you are prevented from turning it into a programmatic mess - just look at some big scripts of popular Gradle projects. And it gets worse if the developers don't write comments on what parts of the script do what.
Gradle scripts allow arbitrary code, but it consequently can turn into a mess. They are partially solving this problem by implementing Kotlin scripts, but the fact that they can change their syntax in any version drives me away.
Some people rightly point out that Gradle is consuming a lot of memory. That is expected from a Java application, though why Maven doesn't have this problem?
Both tools have API for writing plugins. I haven't made any Maven plugins yet, but I made one for Gradle. I'll just say that they are difficult to set up, not even talking about documentation.
Both build tools are able to publish artifacts to the repositories, but in Maven's case publishing to the Central repository is much easier than via Gradle.
Summary: both tools have their advantages, and cannot fully substitute each other.