KAFKA-17811: Separate modules to use different JDKs#17522
KAFKA-17811: Separate modules to use different JDKs#17522chia7712 merged 17 commits intoapache:trunkfrom
Conversation
ce2af51 to
1807f63
Compare
chia7712
left a comment
There was a problem hiding this comment.
@frankvicky thanks for this patch
| options.compilerArgs << "-Xlint:-serial" | ||
| options.compilerArgs << "-Xlint:-try" | ||
| options.compilerArgs << "-Werror" | ||
| options.compilerArgs += ["--release", String.valueOf(minJavaVersion)] |
There was a problem hiding this comment.
Could you please add minClientJavaVersion and minServerJavaVersion?
| // ref: https://github.com/junit-team/junit5/blob/4c0dddad1b96d4a20e92a2cd583954643ac56ac0/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java#L161-L164 | ||
|
|
||
| def modulesNeedingJava17 = [ | ||
| ":core", ":coordinator-common", ":generator", ":group-coordinator", |
There was a problem hiding this comment.
connect:runtime, connect:mirror, connect:test-plugins, and ``connect:file` should use JDK 17 as well
| } else { | ||
| options.compilerArgs += ["--release", String.valueOf(minJavaVersion)] | ||
| } | ||
| } |
There was a problem hiding this comment.
please update scala module as well
|
|
||
| if (name == "compileTestJava" || name == "compileTestScala") { | ||
| options.compilerArgs << "-parameters" | ||
| options.compilerArgs += ["--release", String.valueOf(minJavaVersion)] |
3d9b01a to
35bc484
Compare
| scalaCompileOptions.additionalParameters += ["-Xfatal-warnings"] | ||
| scalaCompileOptions.additionalParameters += ["--release", String.valueOf(releaseVersion)] | ||
|
|
||
| scalaCompileOptions.additionalParameters += ["-release", String.valueOf(minJavaVersion)] |
There was a problem hiding this comment.
streams-scala and streams:test-utils need java 11
| minJavaVersion = 11 | ||
| minClientJavaVersion = 11 | ||
| minServerJavaVersion = 17 | ||
| buildVersionFileName = "kafka-version.properties" |
There was a problem hiding this comment.
Could you please move modulesNeedingJava11 up to line#52?
modulesNeedingJava11 = [":clients", ":streams", ":streams:test-utils", ":streams-scala"]
| // ref: https://github.com/junit-team/junit5/blob/4c0dddad1b96d4a20e92a2cd583954643ac56ac0/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java#L161-L164 | ||
| if (name == "compileTestJava" || name == "compileTestScala") { | ||
|
|
||
| def releaseVersion = isModuleNeedJava11(projectPath) ? minClientJavaVersion : minServerJavaVersion |
There was a problem hiding this comment.
def releaseVersion = modulesNeedingJava11.any { projectPath == it } ? minClientJavaVersion : minServerJavaVersion
| tasks.withType(ScalaCompile) { | ||
|
|
||
| def modulesNeedingJava11 = [":clients", ":streams", ":streams:test-utils", ":streams-scala"] | ||
| def releaseVersion = modulesNeedingJava11.any { project.path.equals(it) } ? |
There was a problem hiding this comment.
def releaseVersion = modulesNeedingJava11.any { project.path == it } ? minClientJavaVersion : minServerJavaVersion
|
Hi @chia7712 |
| gradleVersion = versions.gradle | ||
| minJavaVersion = 11 | ||
| minClientJavaVersion = 11 | ||
| minServerJavaVersion = 17 |
There was a problem hiding this comment.
I think it would be more accurate to say minNonClientJavaVersion as this includes things like tools and other such modules.
There was a problem hiding this comment.
minNonClientJavaVersion looks good to me. Additionally, the connect:api module belongs to client APIs, but in KIP-1032 we decided to bump the Connect module to JDK 17. Could you please add a comment for the Connect module?
chia7712
left a comment
There was a problem hiding this comment.
@frankvicky could you please check the version of jars on your local?
|
Hi @chia7712 |
|
@frankvicky Could you please use |
|
Hi @chia7712 |
|
@frankvicky Could you please update CI file to use JDK 17 and 23 https://github.com/apache/kafka/blob/trunk/.github/workflows/build.yml#L148 |
82b2549 to
7b4bac8
Compare
|
https://github.com/apache/kafka/blob/trunk/build.gradle#L1872 @frankvicky please remove the |
| testRuntimeOnly libs.jacksonDatabind | ||
| testRuntimeOnly libs.jacksonJDK8Datatypes | ||
| testRuntimeOnly runtimeTestLibs | ||
| testRuntimeOnly libs.slf4jReload4j |
There was a problem hiding this comment.
Could you please apply this approach on streams module too?
There was a problem hiding this comment.
I have applied to 4 modules which need JDK 11
e1cd08c to
2c0c438
Compare
|
@frankvicky I think current approach is incorrect. We should make |
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
|
Hey @chia7712 @frankvicky it looks like after merging this PR it's no longer possible (or at least straightforward) to run tests in client modules (specifically streams) from within the IDE (IntelliJ specifically). I'm getting: I've tried manually setting the module in the project settings but that doesn't seem to work. Would be good to document something in the project README. Note that it still works using cc @ableegoldman who was running into similar issues |
Could you please share the details to me? For example, how do you run the tests by IntelliJ? |
|
@agavra Are you using JDK 11 to run the streams tests? If so, that could be an issue since the generator module requires JDK 17. I assume all Kafka developers should use JDK 17, as we typically build the entire project during development. |
|
🤦 this is why I shouldn't work at night, I had set the module versions to JDK 17 but not the project version to JDK 17. It now works, thanks @chia7712. |
We do indeed need to compile the project with 17, but we should recommend that anyone working on the clients (or any other modules that still support 11) at least set their IDE's language version to JDK11 to avoid accidentally using APIs that don't exist back in 11 (looking at you |
|
@ableegoldman Thanks for your feedback. I agree that we should prioritize making our developers' experience better. I plan to add sourceCompatibility back to build.gradle since IntelliJ IDEA sets the language level based on sourceCompatibility by default (Gradle Documentation). The screenshot below demonstrates that IntelliJ IDEA can automatically highlight unsupported usages. With this change, developers won't need to manually configure the language level. |
|
open KAFKA-18186 to address this. @ableegoldman please feel free to share your thoughts on this approach. |
|
I see some confusion here and I'll try to clarify it.
We should make sure it's possible to run tests with Java 11 for the modules that support it since it's possible to have issues at runtime that only affect a particular version.
The expected behavior is that the IDE & gradle plugin support the --release flag which has the correct behavior (it sets the appropriate source and binary versions and ensures the standard library signatures also match it).
Are we sure the Gradle plugin doesn't handle this properly? If so, we should add the workaround, but also file a ticket with them. See the following for a similar situation for the Scala (the issue here seems to be for Java instead): |
that makes sense. open https://issues.apache.org/jira/browse/KAFKA-18192 to handle it.
The root cause is that we set the compiler arguments directly instead of using Gradle's recommended |
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>





JIRA: KAFKA-17811
This is sub-task to drop broker and tools support for Java 11.
Committer Checklist (excluded from commit message)