https://kotlinlang.org logo
#gradle
Title
# gradle
s

Slackbot

12/14/2023, 10:42 AM
This message was deleted.
v

Vampire

12/14/2023, 10:51 AM
What do you mean with "why doesn't it take project's java version"? If you run from commandline how would "project's java version" be defined? It uses what you have in
JAVA_HOME
or if not available what is in
PATH
to run Gradle, and that obviously is Java 21 and your Gradle version does not support that yet.
which is 21 and is not in the compatibility matrix
It is, starting with Gradle 8.5 you can run Gradle with Java 21
d

Djuro

12/14/2023, 10:53 AM
Then I misunderstood it, but before adding a new project for the plugin, everything worked fine from the terminal
now nothing wants to work, not even a single task, always giving the same erro
but from the UI it works like magic so I thought that before it used to take that one while running 🤷
project is not using 8.5, 8.0 rather
But tgats doesnt seem to be the issues it worked before
v

Vampire

12/14/2023, 11:18 AM
The main point why Gradle does not support running on Java 21 is that the bundled Kotlin version does not yet support compiling for 21. By adding that plugin in Kotlin language, you try to compile it for Java 21 and that does not work. Which Java version is used to run Gradle from the IDE depends on what you selected in the Gradle settings in the IDE.
Just use a Java version that is compatible with 8.0 when running from the commandline and it should work
With not having the plugin, you are not triggering the code path that is incompatible with Java 21 so you might just have been lucky that it worked.
d

Djuro

12/14/2023, 11:23 AM
I didnt want to do that but yeah i will change the default one in the path thank you
v

Vampire

12/14/2023, 1:35 PM
You can just do it in the currently open shell, you don't necessarily need to change the default. You can even set it just for the current invocation.
d

Djuro

12/14/2023, 1:40 PM
Yeah thank you that definitely works, i just thought it can autoresolve the jdk version with some magic without it 😅
v

Vampire

12/14/2023, 2:07 PM
Not for running Gradle itself, no. For building your code, yes, if you use JVM toolchains feature. So alternatively you could set the JVM toolchain for the plugin project to Java 8 for example. Then it should also work.
d

Djuro

12/14/2023, 2:09 PM
I will take a look into toolchains also, totally forgot about it, thank you
👌 1