Hello all. :wave: I have some software engineerin...
# getting-started
m
Hello all. 👋 I have some software engineering experience but many years ago and different languages (C++, C#). I was trying out Kotlin and had some basic questions about adding dependencies. 🧵
I'm using InteliJ IDEA as an IDEA and, when creating a new project, you obviously get this...
image.png
I don't remember what I picked for
Build system
in my current project. First question, after a project is created, is there a way to to see what you've chosen and switch it (i.e. from IntelliJ to Gradle)?
Why was I considering switching to Gradle? I found this documentation...
...about adding dependencies but (and I could be reading this wrong) it seems to be oriented around if I had chosen Gradle as my
Build system
(which again I think I picked IntelliJ).
c
95% of people use Gradle in real projects, IntelliJ-based projects are basically only used for prototyping
👍 1
The simplest way is probably to create a new project with Gradle and copy your code to it. Or, you can run
gradle init
which will give you a different wizard
k
If your project root already has a
.gradle
directory, then you've probably created the project with Gradle.
a
@CLOVIS I would not be so sure about 95%, because almost all my projects use Maven. @Matt Kessler I do not create project in IntelliJ, but either in Gradle/Maven or just copy an empty example (like Spring boot init)
c
2023 numbers, indeed it's not 95%
(still, my point was that no one uses IntelliJ's build system 😅)
k
How come those numbers add up to 111%?
c
Some people use both Gradle and Maven, on different projects
Wait still it's "most regularly" 🤔 I don't remember how the question was asked exactly, but my guess is it was multi-answer
m
I would want to be with the mainstream on
Build system
so it sounds like I need to start a new project using Gradle on that front. That should be easy enough. It would still be nice if IDEA gave you any easy way to switch after project creation.
a
It will
k
But after you've modified the Gradle build file to add any level of complexity to the build process, I wouldn't trust any automated system to successfully convert it to a different build system. Not even an AI-based one.
m
Disclaimer. I recognize that the following is a nOOb question but I've never messed with Gradle before. I created a new project in IDEA with
Build system: Gradle
. I also had the
Add sample code
checkbox selected. With no changes to the sample code, I simply tried to build but got...
Copy code
Inconsistent JVM-target compatibility detected for tasks 'compileJava' (24) and 'compileKotlin' (23).
A bit of searching told me that I had to add this to build.gradle.kts...
Copy code
kotlin {
    jvmToolchain(24)
}
...which I did but rebuilding leads me to the same exact error. Thoughts?
k
Only the latest versions of Gradle are compatible with Java 24. It might be safer to use Java 23 everywhere, if you're not sure what version of Gradle the IDE is using.
c
A bit of searching told me that I had to add this to build.gradle.kts...
Are there multiple
build.gradle.kts
files? This should solve the problem
m
I will check later to see what version of Gradle I have. This page…
… seems to suggest that you need 8.14 for JVM 24.
c
If you're just starting out, don't hesitate to target lower JVM versions (e.g. 21 is the latest LTS). Very few changes in recent JVM versions, especially as seen from Kotlin
👍 1
m
image.png
Weird. To me, the above looks like I'm using Gradle 8.14 which their documentation says should work with JVM 24. 🤔
But, yea, good call on downgrading JVM. I installed 23, updated my project settings, rebuilt and...
Copy code
Process finished with exit code 0
c
Everything looking good then
Currently, most libraries support Java 11+ or 17+, so the exact version you choose doesn't matter much
👍 1