Skip to content

Commit

Permalink
Fix Dataflow ARM PostCommit failing Java21 (#29444)
Browse files Browse the repository at this point in the history
* Suppress lint warning in Java21

* Fix io/kafka classNotFound when compile with Java21
  • Loading branch information
Abacn authored Nov 16, 2023
1 parent deabcd1 commit 729c4de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,11 @@ class BeamModulePlugin implements Plugin<Project> {
'unchecked',
'varargs',
]
// Java21 introduced new lint "this-escape", violated by generated srcs
// TODO(yathu) remove this once generated code (antlr) no longer trigger this warning
if (JavaVersion.current().compareTo(JavaVersion.VERSION_21) >= 0) {
defaultLintSuppressions += ['this-escape']
}

project.tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
Expand Down
5 changes: 3 additions & 2 deletions examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ configurations.sparkRunnerPreCommit {
dependencies {
implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
implementation library.java.vendored_guava_32_1_2_jre
if (project.findProperty('testJavaVersion') == '21' || JavaVersion.current().equals(JavaVersion.VERSION_21)) {
// this dependency is somehow needed for compile only under Java21
if (project.findProperty('testJavaVersion') == '21' || JavaVersion.current().compareTo(JavaVersion.VERSION_21) >= 0) {
// this dependency is a provided dependency for kafka-avro-serializer. It is not needed to compile with Java<=17
// but needed for compile only under Java21, specifically, required for extending from AbstractKafkaAvroDeserializer
compileOnly library.java.kafka
}
implementation library.java.kafka_clients
Expand Down
2 changes: 1 addition & 1 deletion runners/google-cloud-dataflow-java/arm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ configurations { examplesJavaIntegrationTest }

dependencies {
examplesJavaIntegrationTest project(project.path)
// TODO(yathu) Include full test classpath once gradle shadow plugin does not support Java21
// TODO(yathu) Include full test classpath once gradle shadow plugin support Java21
if (project.findProperty('testJavaVersion') == '21' || JavaVersion.current().equals(JavaVersion.VERSION_21)) {
examplesJavaIntegrationTest project(path: ":runners:google-cloud-dataflow-java")
} else {
Expand Down
5 changes: 5 additions & 0 deletions sdks/java/io/kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ dependencies {
implementation library.java.avro
// Get back to "provided" since 2.14
provided library.java.kafka_clients
if (JavaVersion.current().compareTo(JavaVersion.VERSION_21) >= 0) {
// this dependency is a provided dependency for kafka-avro-serializer. It is not needed to compile with Java<=17
// but needed for compile only under Java21, specifically, required for extending from AbstractKafkaAvroDeserializer
compileOnly library.java.kafka
}
testImplementation library.java.kafka_clients
implementation library.java.slf4j_api
implementation library.java.joda_time
Expand Down

0 comments on commit 729c4de

Please sign in to comment.