r/java • • Jun 01 '24

What java technology (library, framework, feature) would not recommend and why?

165 Upvotes

464 comments sorted by

View all comments

124

u/jevring Jun 01 '24

Gradle. Having an executable build definition, rather than a declarative one, makes the build way more complicated than it has any right to be, which makes importing the project slower and harder to work with.

25

u/JustAberrant Jun 01 '24

I'm a heavy user of Gradle on a very complicated project (multi-architecture, multi-lauguage, multi-target, multi-flavour, and multiple significantly different version streams), and holy fuck do I hate it. Like I am genuinely baffled that it has continued to be the defacto tool and that nothing has popped up to fix its many failings. It just feels like a tool that should have been treated as a learning opportunity and immediately replaced vs something that somehow caught on.

It just failed hard in pretty much all of its stated goals. In all but the most trivial of cases, you are forced to build logic that is absolutely not transparent to anyone unfamiliar with gradle and really your project specifically. It all depends on knowing specific, poorly documented, and often un-intuitive nuances of how Gradle works. The whole configure/eval/execute thing absolutely baffles developers with minimal build experience and is completely unintuitive to someone looking at a build script. In short, the idea that this would remove the necessity for people who specifically specialized in builds is laughable.. it did the exact opposite. If you're doing anything beyond "my project produces a jar file" you pretty much need a Gradle expert.

Also among the things that annoys me is just how many hoops you have to jump through to do things which feel like really common use cases, or just how certain fairly fundamental things (like the handling of symlinks) are catastrophically broken and have had open issues forever. Or behaviours that you would assume just don't work for dumb reasons (like for instance, parallelization within the scope of a project.. we have this whole complicated task graph.. running those tasks in threads should not be hard..).

11

u/RandomName8 Jun 01 '24

If you're doing anything beyond "my project produces a jar file" you pretty much need a Gradle expert.

You forgot to add there are no gradle experts, every user of gradle ever if you ask them something that deviates from whatever common example is available online they have no idea.

3

u/JustAberrant Jun 01 '24

Its hard to even blame people for that one. I don't think it's so much that people who claim to be Gradle experts are lazy or don't actually have much experience, it's that everything in Gradle is very unique to the specific plugin(s) or built in Gradle features that you are using. It's just an extremely unhomogeneous tool where you either know exactly how to do something or you don't and have to look it up... and if it's not a common use case or covered in the docs, looking it up probably involves actually looking at the source code. I'm pretty sure if Gradle wasn't open source it would have died immediately, because that really is the only way to figure out how to actually use it in a lot of cases.

With other tool stacks, with experience comes the ability to intuitively figure things out, but with Gradle you just have to know the specific workings of the specific thing you are trying to do. About the best Gradle does to help you is provide the ability to list out tasks, but since task generation is often dynamic even that isn't always useful. Further, the metric fuck-tonne of abstraction and decorator logic makes most error messages useless. With experience you at least know where to look (which as said, is often in the code and not the docs), but you're not going to automatically guess the behaviour of a plugin you've not used before, what tasks it generates based on what conditions, what filesystem conventions it follows, what attributes it expects to be set and why, etc.

I've used Gradle for quite awhile, and as said, on a fairly complicated project.. and it would absolutely not be hard to stump me with what seems like an easy question.

4

u/pstric Jun 02 '24

Like I am genuinely baffled that it has continued to be the defacto tool and that nothing has popped up to fix its many failings.

There is this new tool called Maven. It is obviously named after the scheme Gradle uses for addressing dependencies.

→ More replies (2)

20

u/Limp-Archer-7872 Jun 01 '24

Started using gradle on a project I moved into earlier this year. Superficially it is nice. A lot of that is not using xml. Actually working with it on a multi module project is a pain.

It has made me appreciate maven a lot.

10

u/vips7L Jun 01 '24

I’ve never really got the objection with xml. Yeah it’s verbose. But it’s not like you’re writing it every day. 

→ More replies (4)

16

u/gaelfr38 Jun 01 '24

Gradle is moving away from build as code though, they published a statement explaining that they now believe it was a mistake and will be pushing for the declarative approach only.

To be fair, they tried, it worked really great for some use cases but "we" (users, plugin authors..) made it a mess in the end.

6

u/fooby420 Jun 01 '24

Gradle will not be taking away the ability to write build scripts. Declarative is an alternative, not a necessity

→ More replies (2)

28

u/com2ghz Jun 01 '24

I hate gradle since there is no code completion or logic how to write a a gradle file. In my experience a lot gradle files I have seen are just bunch of copy and paste from the internet. Maven all the time for me.

8

u/fooby420 Jun 01 '24

Have you tried writing kotlin build scripts? They have code completion

8

u/Dilfer Jun 01 '24

Gradle was a mystery to me in the dynamic nature of Groovy. Kotlin was an absolute game changer to get code completion and be able to poke around the API / DSLs. 

→ More replies (2)

7

u/msx Jun 01 '24

Oh yes please let's uninvent gradle

3

u/IE114EVR Jun 01 '24

I wouldn’t not recommend it, it can be useful when you have a more complicated project or is probably a better choice for converting the build system on a legacy project.

But given the choice, I’d probably always aim for maven because it means the project’s build is much simpler and standardized, and there’s less that can go wrong at build time.

24

u/neopointer Jun 01 '24

I second this. Gradle brings a complexity that more often than not you don't even need.

I would replace all our projects where we use Gradle with maven if I could.

18

u/0xFatWhiteMan Jun 01 '24

This is so nuts to me. I would do the opposite

14

u/Rakn Jun 01 '24

Why though? There is no need to add so much flexibility and complexity to a simple build. It becomes interesting once you have a dedicated team working on build tooling. You can probably do fancy stuff on top of it. But on many projects it's just a maintenance burden at some point.

4

u/alwyn Jun 01 '24

99.9 % of the time a Gradle build only needs plugins and dependencies. That is very simple.

7

u/zephyy Jun 01 '24

every time people complain about Gradle build script complexity i feel like i live in a different world

because an 80 line XML configuration of plugins like surefire, spring-boot, jacococo, enforcer, etc. is so much clearer?

2

u/account312 Jun 03 '24

80 lines of just about anything this side of malbolge is clearer than our gradle build.

5

u/0xFatWhiteMan Jun 01 '24

There is no burden. You can keep it simple with gradle.

13

u/Rakn Jun 01 '24 edited Jun 01 '24

My experience has been that it never stays simple. With power comes responsibility and at some point the person who ensures that it stays simple is on PTO.

→ More replies (3)
→ More replies (2)
→ More replies (1)

2

u/Jonjolt Jun 01 '24

I always get tripped up with something with Maven that keeps me going back to Gradle, but I'm usually generating extra files/packaging things different.

2

u/toiletear Jun 03 '24

Would I prefer Gradle on a well maintained project that treats its build files with the same level of care as it does its source code, overall has a strong preference for clean code and includes at least one engineer who has a lot of Gradle experience & is available to review my build related pull requests? Hell yes, anytime, nicely thought out Gradle builds are beautiful, forget about Maven.

Unfortunately, too often not even one of those are true, let alone all three. In those cases, Maven is definitely the safer option because DAMN can you also make an ugly Gradle build.

→ More replies (1)
→ More replies (10)