KAFKA-18186: set options.release to make Intellij configure suitable language level automatically#18104
Conversation
| @@ -125,6 +125,7 @@ ext { | |||
|
|
|||
| options.compilerArgs << "-encoding" << "UTF-8" | |||
| options.compilerArgs += ["--release", String.valueOf(releaseVersion)] | |||
There was a problem hiding this comment.
Could you please try to use options.compilerArgs += ["--release", String.valueOf(releaseVersion)] instead of options.compilerArgs += ["--release", String.valueOf(releaseVersion)]. The former can set the sourceCompatibility automatically (see https://github.com/gradle/gradle/blob/784ffbe7b04e3dd31f4e05e12906efc7a410757f/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/JavaBasePlugin.java#L331)
There was a problem hiding this comment.
typo: options.release = releaseVersion -> we should use this instead
|
It works on my local "IntelliJ IDEA 2024.3 (Community Edition)". |
|
@agavra @ableegoldman Could you please take a look, as you provided feedback on #17522? With this patch, IntelliJ IDEA can automatically recognize the language level for each module. |
|
Adding Version details: |
|
@ijuma Thank you for your report. Could you please try using JDK 17 features in the clients module, as here? I encountered the same issue as you and will investigate it later. However, the main improvement is that IntelliJ IDEA can recognize the supported features for different modules, even though the project structure doesn't seem to work correctly |
|
Good point @chia7712 - it seems like the internal model for IntelliJ is actually correct even though the settings screen isn't. One other inconsistency I noticed is that IntelliJ seems to only have a single Java standard library association, so whichever SDK is picked at the project level will be the one one used when someone follows a class/method definition (even if the actual version used by some modules may be older). So, to summarize:
2 and 3 are unrelated to this PR, but I think good to do if people have cycles. |
|
Thanks for @ijuma suggestion
I file a Jira to trace it KAFKA-18203
I will also file an issue to intellij community |
|
I'm trying to test this out by setting the language level for the streams module under 'Project Structure', but:
Am I doing something wrong? |
|
Hello @ableegoldman, We should not set java version in the Project Structure > Project Settings > Modules, when we import the new kafka project, and refresh the gradle build, You can test below in different modules
In Project Structure > Project Settings > Modules it also is project default, but I file a issue to intellij community to trace it. |
Apologies, but |
options.release to make Intellij configure suitable language level automatically
|
This change breaks the "version" used by joint compilation, resulting in the Java code in the core module being compiled into incorrect byte-code. I have opened KAFKA-18242 to address this issue. As a simple solution, we need to add |
… language level automatically (apache#18104) Reviewers: "A. Sophie Blee-Goldman" <ableegoldman@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
… language level automatically (apache#18104) Reviewers: "A. Sophie Blee-Goldman" <ableegoldman@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>





Jira: https://issues.apache.org/jira/browse/KAFKA-18186
To enhance the developer experience, when the user runs
./gradlew idea, IntelliJ IDEA should automatically configure the Java settings.test in my local

Committer Checklist (excluded from commit message)