Repository: apache/netbeans
Issue: groovy.lang.MissingPropertyException from Micronaut-Core

### Apache NetBeans version

Apache NetBeans 18 release candidate

### What happened

Clone micronaut-core from GH, this gets you to default branch 4.0.x
Install VSNetBeans 18.0.0 RC2 https://nightlies.apache.org/netbeans/candidate/vsix/ use GraalVM 22.3.0 JDK17.
In VSNetBeans enable JavaLSP and Groovy support, both are Enabled.
Open cloned micronaut-core.
later you will see following exception thrown several times and shown also in VSCode dialog during project background scanning.
```Failed to retrieve project information for: /Users/mbalin/micronaut/micronaut-core/aop
Reason: groovy.lang.MissingPropertyException: Could not get unknown property 'sourceCompatibility' for task ':aop:compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
groovy.lang.MissingPropertyException: Could not get unknown property 'sourceCompatibility' for task ':aop:compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
	at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
	at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
	at org.gradle.api.internal.AbstractTask.property(AbstractTask.java:571)
	at org.gradle.api.DefaultTask.property(DefaultTask.java:169)
	at org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.detectSources(NbProjectInfoBuilder.java:1088)
	at```
see attachement for the full stack trace.
This DOES NOT happen when Groovy is Disabled.

### How to reproduce

See steps above.
[groovy.lang.MissingProperyExc.txt](https://github.com/apache/netbeans/files/11347233/groovy.lang.MissingProperyExc.txt)



### Did this work correctly in an earlier version?

No / Don't know

### Operating System

macOS venture

### JDK

GraalVM 22.3.0 JDK17

### Apache NetBeans packaging

Apache VSNetBeans for VSCode

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Changed files:
extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java

diff --git a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
index 126ed14e36..ae4ac827e7 100644
--- a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
+++ b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
@@ -1083,13 +1083,36 @@ class NbProjectInfoBuilder {
                         String langId = lang.toLowerCase();
                         Task compileTask = project.getTasks().findByName(sourceSet.getCompileTaskName(langId));
                         if (compileTask != null) {
-                            model.getInfo().put(
+                            Object o = null;
+
+                            // try to get from Kotlin options; breaking change in kotlinCompile 1.7+ does not derive from
+                            // SourceTask and does not have source/targetCompatibility. It reportedly ignores those options
+                            // even before 1.7
+                            if ("KOTLIN".equals(lang)) {
+                                o = getProperty(compileTask, "kotlinOptions", "languageVersion");
+                            } 
+                            if (o == null && compileTask.hasProperty("sourceCompatibility")) {
+                                o = getProperty(compileTask, "sourceCompatibility");
+                            }
+                            if (o != null) {
+                                model.getInfo().put(
                                     propBase + lang + "_source_compatibility",
-                                    compileTask.property("sourceCompatibility"));
-                            model.getInfo().put(
-                                    propBase + lang + "_target_compatibility",
-                                    compileTask.property("targetCompatibility"));
-
+                                    o.toString()
+                                );
+                            }
+                            o = null;
+                            if ("KOTLIN".equals(lang)) {
+                                o = getProperty(compileTask, "kotlinOptions", "jvmTarget");
+                            } 
+                            if (o == null && compileTask.hasProperty("targetCompatibility")) {
+                                o = getProperty(compileTask, "targetCompatibility");
+                            }
+                            if (o != null) {
+                                model.getInfo().put(
+                                        propBase + lang + "_target_compatibility",
+                                        o.toString()
+                                );
+                            }
                             List<String> compilerArgs;
 
                             compilerArgs = (List<String>) getProperty(compileTask, "options", "allCompilerArgs");