Do you need to learn kotlin or gradle?

Must be my inexperience with gradle then (we use maven at my work place). My main point is, I don’t share the experiences of the OP. I don’t spend too much time setting up a new project. I migrated from java though, so I already had some experience with some of the stack.

I feel the same, but looking at discussions in the internet, I’m probably a minority. Today I had a funny situation in my work, which is a good example of typical problems with Gradle.

My teammate asked if I can help with problems with Gradle. They were adding a Gradle plugin which was supposed to generate some Java code. They showed me their config, where they apply the plugin, configure the input dir, configure the output dir, then copy generated sources to another dir, add that new dir to source sets, mix it with other classes, etc. One can say: a typical code for generating the source code on the fly. They struggled the whole day to get it working, because it either couldn’t find some dependencies or something else didn’t work. I suggested one thing: let’s… remove everything. Apply the plugin and do nothing else. It worked :smiley:

Problem is with mentality. People try to write a step-by-step script in Gradle. They try to do things manually, but Gradle still uses its automations and they got into conflicts. Above story is not the first time, I can’t count how many times I saw people using 50-lines long Gradle file, which I believe could be replaced with 10 lines. Then they blame Gradle both for the fact their config is complicated and that it explodes whenever they need to change anything. I usually do the opposite. I start with the no-code solution, then apply a minimal set of changes to get my thing working. This approach usually works well with Gradle.

MPP is another story though. In my life I had an opportunity to write scripts for building Android apps using low-level tools from Android SDK (so without Gradle). I cross compiled from linux to iOS. I used some multiplatform Android/iOS technology (I don’t remember which one). All of these projects were a pain, all of them were exploding from time to time. All of them were hard to setup on a new machine. If anyone knows a multiplatform technology which supports backend, browser, Android and iOS and it just works then please let me know.

1 Like

This literally happens so often at my work with older Gradle projects. Recent Gradle versions are pretty good about resolving stuff, but for older projects, so often when I’m loading it up for the first time I have to comment out EVERYTHING and then gradually uncomment things piece by piece, letting Gradle resolve the new configuration one bit at a time. Because if you try to resolve the whole build file at once, Gradle just can’t do it. It’ll get stuck on one broken thing which is only broken because it hasn’t processed another piece of information that would resolve the broken thing!

My opinion on Gradle is that it works well enough for simple things, but if you try to take advantage of the complexity it allows, you’ll almost always run into problems. Which makes me wonder why it allows such complexity in the first place. “Giving you enough rope to hang yourself”, and then plenty more rope.

I do agree, but Gradle allows you to do this complicated stuff, most of tools which people mention that “they just work” just cannot do anything complicated

I was really looking forward to creating a backend server in Kotlin, but I just spent an evening trying to build Kotlin with JDK 21 and failed because I couldn’t figure out how to create the appropriate gradle. Reading above, it sounds like I could still use Kotlin if I relied entirely on IntelliJ IDEA for builds, but I’m a Java dev using maven and find command line builds far more reliable than IntelliJ builds, which seem to be non-deterministic (a successful build from the command line tells me to keep mucking with IntelliJ until it properly builds). I’m hesitant to even try using maven with Kotlin given the dearth of resources for doing so. I really don’t need another headache in my life. I now find myself exploring non-Kotlin solutions (and non-Java, because I want concurrent DB access, and JDBC does not support virtual threads). -sigh-

Honestly Kotlin with Maven isn’t too bad. Just apply the kotlin-maven-plugin and it works.

My experience, and what I’ve seen from others, is that if you’re just doing a plain JVM app using Kotlin, Maven or Gradle are fine. If you’re doing an Android app with Kotlin and Gradle, it’s mostly fine. It’s the MPP and Native where people really seem to have problems.

Skater901, thanks for the perspective on maven. I was able to produce a pom that builds Kotlin 2.1.10 for JDK 21, and it only took 40 minutes of experimentation. I’m surprised that the latest IntelliJ IDEA CE by default creates a POM for a pre-2.x Kotlin using JDK 17. I’ll give Kotlin another try. (I need JDK 21 for the latest jOOQ.)

println(KotlinVersion.CURRENT) tells me that I’m actually running 1.9.24, which seems to be the most recent version supported by the Kotlin plugin, at least in Maven. I do have K2 enabled. 1.9.24 should suffice, but it would be nice to run the latest Kotlin.

UPDATE: I was able to get it to use Kotlin 2.1.10, but I’m not really sure what did the trick. Maybe call it 1.5 hours total to figure out.