Well, the rapid changes of Java put pressure on the tool platforms, and
JVM based languages. That makes our life more difficult.
As of NetBeans, it was quite a fight to move away from Java 8 as a
runtime platform. That does not mean that NetBeans does not support
Java 8 any more, rather, that You need to run NetBeans at least on Java
11. As of NetBeans 20, It runs on Java 11 - Java 21, while supports Java
8 - Java 21
As of Gradle. Gradle supports Groovy and Kotlin as base of its DSL.
Usually when the new JVM comes out both Groovy and Kotlin takes some
time to support running on the new JVM. So they are not in an easy
position, especially as they still need to support running on Java 8 fro
a while.
In order to cope with that challenge Gradle stated to use a Java
Toolchain system, which decouples the Runtime Gradle is running on from
the Java version it is using during the builds.
If I remember well, on 8.4 they found themself in the situation with
Java 21, where the Groovy parts were able to run on Java 21 while the
Kotlin related things were not able to run on Java 21 VM. Java 21
Toolchain was ready by then. That means Gradle 8.4 itself is not able to
run on Java 21, but able to use Java 21 for builds.
With Gradle 8.5, it is also able to run on Java 21 VM.
It would be nice if NetBeans would be automatically select a good Java
Runtime for Gradle out of the box though. We have all the parts in
NetBeans to be able to make it happen, somebody just would need to do
the job.
Addendum: Before Gradle 8.5, Gradle java projects, generated with Gradle
were using the Java version of the Gradle Runtime as the Jave version
for the new project. That's been changed as of:
https://docs.gradle.org/8.5/release-notes.html#build-init
So what is happening now when creating a new project on NB20 is running
on Java 21 with Gradle 8.4 Tooling (that's the one NB20 is bundling),
when using the defaults .
1. NetBeans invokes gradle init with Java 21, as Gradle 8.4 Groovy
parts works with Java 21, it will create a new project, with java
toolchain 21
2. NetBeans knows that Gradle 8.4 is not Java 21 Runtime comaptible
(that's hard coded in NB). So it simply refuse to load the project,
while the Gradle Java runtime is set to Java 21 (Default).
That's when people get confused.
Again NB should do a better job selecting the Gradle Java runtime.
On 12/3/23 17:20, Ernie Rael wrote:
On 23/12/03 3:51 PM, Laszlo Kishalmi wrote:
Well, unfortunately gradle init only supports java version
specification since Gradle 8.5
NB20 is bundled with Gradle 8.4.
The gradle 8.4 release notes say
"Java 21 is now supported"
if that matters.
There is a bit workaround needed to run Java 21 projects with Gradle.
I can run the project tests with no workaround.
Also, I manually set the gradle version for the project to 8.5
./gradlew wrapper --gradle-version 8.5
The problem icon is still there and the message says
"Java version: 21 ... not supported by Gradle 8.5"
Both 8.4 and 8.5 claim to support JDK-21. This all makes no sense.
I think (I don't remember) that I could run the project tests when it
was gradle 8.4 as well with no workaround.
This all makes me wonder if there's something hardcoded in NetBeans
about JDK-21 and gradle.
-ernie
Set the Java Runtime version for Gradle in Tools > Options > Java >
Gradle to Java 20 or below.
From there you can use any Java version in your Gradle projects,
whatever that Gradle version support.
Gradle 8.4 does support Java 21 using Java Toolchain, should work.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
On 12/3/23 13:30, Ernie Rael wrote:
Running NB-20, jdk21.
The goal is to play with some JDK-21 APIs...
Creating a project using NB's "New Project > Java with Gradle".
I can build and run the default "Library" and test. But there's the
warning icon and "Resolve Project Problems".
Any way to get rid of the warning?
-ernie
"Resolve Project Problems"
The Java version: 21, that is selected for the project is not
supported by
Gradle 8.4.The IDE will attempt to use Gradle 8.4 to gather the project
information.
Possible solutions:
Upgrade your Gradle version on your project
Select Java Runtime 20 (or below), on Build > Gradle Execution
settings, to avoid this problem!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists