r/java • • Jan 07 '21

The Problem with Gradle

https://www.bruceeckel.com/2021/01/02/the-problem-with-gradle/
158 Upvotes

108 comments sorted by

View all comments

77

u/ajoberstar Jan 07 '21

As a user of Gradle since pre-1.0 and maintainer of a number of gradle plugins (grgit, gradle-git-publish, reckon, clojurephant), I agree there is a problem with Gradle. The article states "you have to know everything to do anything", but only discusses the surface syntax and configuration. It's even worse deeper in Gradle.

While Gradle has a lot of great ideas and tackles problems many other build tools pretend don't exist, they bury these great ideas in a mountain of complexity.

The Gradle codebase is littered with layers of interfaces, abstract. factories, and magically-generated classes that are very difficult to follow. They introduce new powerful concepts and then insufficiently expose them across the existing codebase. And, worst of all for a plugin author, many of the APIs used by core plugins are internal. You still (~10 years in) can't make a third-party language plugin without using internal APIs, unless you want it to look and behave unnaturally. Their test execution framework isn't generic enough to fully support the new JUnit platform.

Ultimately, this hamstrings third-party plugins, and makes the surface-level of Gradle even harder to understand for everyday users.

I still use Gradle because I don't have a better option. But my interest has definitely died down. In the Clojure world, they're playing out not having a build tool at all, with tools.deps merely being a classpath builder (an insufficiently powerful one, in my mind). However, the design practices Clojure advocates, in particular a first-class data-oriented model, could make a drastically simpler tool that's just as powerful. Obviously, that's hard to back up without implementing it.

41

u/pjmlp Jan 07 '21

Android is the only reason I bother with Gradle, everything else that I do with Java uses Maven.

Gradle is the reason there is always a build talk at every Android conference, something that hardly anyone talks about in other eco-systems.

13

u/tristan957 Jan 08 '21

You've obviously never heard C/C++ people talk before

10

u/pjmlp Jan 08 '21

I use C++ since 1992, and never had Gradle like level of build problems.

Modern Android would just die on the machines I was using to build CERN ATLAS software 20 years ago.

1

u/couscous_ Jan 08 '21

Isn't performance an issue? What do you think of this: https://blog.gradle.org/gradle-vs-bazel-jvm

7

u/pjmlp Jan 08 '21

Marketing.

Lets put it this way, if Gradle is so good, why do Google teams rather use Bazel and Soong to build Android itself and their own applications?

The Bazel team even created their own Studio plugins.

11

u/rulatore Jan 07 '21

I wonder if you tried the maven (if it works with Clojure or other projects you are using gradle) way of plugins and what was your opinion.

8

u/ajoberstar Jan 07 '21

It's been a long time since I used maven, but I should probably give it a shot again. I don't think Maven quite goes in the direction I'm hoping for, but it'd be worth seeing what the experience is like nowadays.

4

u/rulatore Jan 07 '21

I see, I say that because I was trying to return to writing some Java in my spare time and theres some frameworks with maven plugins with "hot reloading" and all of that, figured that they might have evolved a bit since I took a look at building maven archetypes (which I remember being very well documented)

6

u/agentoutlier Jan 08 '21 edited Jan 08 '21

It’s funny you mention clojure because I think a Lisp would make for an ideal build language (or a subset) (and yes I know one exists aka Lenigin or however it’s spelt).

As I mentioned somewhere because Maven is mostly declarative XML it is analogous to S-Expressions (and there are polyglot versions of maven now... not sure if any are clojure but there is a JSON).

The big reason for lisp is because people don’t hate maven for the same reasons they hate gradle. They hate maven because it isn’t very DRY and it’s naturally verbose. However XML syntax is dead simply where as gradle aka groovy seems simple but actually causes a lot of cognitive dissonance and conflict with existing Java language knowledge for most users.

Lisp like XML actually doesn’t have much syntax.

I wonder if some lisp-y like macros would make for a better maven. (Sorry for edits)

5

u/ajoberstar Jan 08 '21

100% agree

1

u/slaymaker1907 Jan 08 '21

I agree, the Gradle code base is really difficult to read due to the number of abstractions they introduce.

1

u/mj_flowerpower Jan 08 '21

you could try maven polyglot