Skip to content

Commit 46e2dba

Browse files
tkaymakclaude
andcommitted
build: add runners/spark/4/ build configuration
Add the Gradle build file for the Spark 4 structured streaming runner. The module mirrors runners/spark/3/ — it inherits the shared RDD-base source from runners/spark/src/ via copySourceBase and adds its own Structured Streaming implementation in src/main/java. Key differences from the Spark 3 build: - Uses spark4_version (4.0.2) with Scala 2.13. - Excludes DStream-based streaming tests (Spark 4 supports only structured streaming batch). - Unconditionally adds --add-opens JVM flags required by Kryo on Java 17 (Spark 4's minimum). - Binds Spark driver to 127.0.0.1 for macOS compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fb95a66 commit 46e2dba

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

runners/spark/4/build.gradle

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
def basePath = '..'
20+
/* All properties required for loading the Spark build script */
21+
project.ext {
22+
// Spark 4 version as defined in BeamModulePlugin; requires Scala 2.13 and Java 17
23+
spark_version = spark4_version
24+
spark_scala_version = '2.13'
25+
copySourceBase = true // copy shared base into build dir; Spark 3 remains the primary dev version
26+
archives_base_name = 'beam-runners-spark-4'
27+
}
28+
29+
// Load the main build script which contains all build logic.
30+
apply from: "$basePath/spark_runner.gradle"
31+
32+
// Force Spark to bind to 127.0.0.1 so tests pass on machines where the hostname
33+
// doesn't resolve to a bindable address (e.g. mac.lan in macOS VPN environments).
34+
// Spark 4 always requires Java 17, so unconditionally add the --add-opens flags
35+
// required by Kryo and other libraries that use reflection on JDK internals.
36+
test {
37+
systemProperty "spark.driver.host", "127.0.0.1"
38+
systemProperty "spark.driver.bindAddress", "127.0.0.1"
39+
jvmArgs "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
40+
"--add-opens=java.base/java.nio=ALL-UNNAMED",
41+
"--add-opens=java.base/java.util=ALL-UNNAMED",
42+
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED"
43+
}
44+
45+
// Add Spark 4 structured streaming source on top of the copied shared base.
46+
sourceSets.main.java.srcDirs += "src/main/java"
47+
sourceSets.test.java.srcDirs += "src/test/java"
48+
49+
// Exclude DStream-based streaming tests from the shared base copy: the Spark 4 module
50+
// supports only structured streaming (batch) and does not include legacy DStream support.
51+
// Streaming test utilities also depend on kafka.server.KafkaServerStartable which was
52+
// removed in Kafka 2.8.0 (the first Kafka version with a _2.13 artifact).
53+
tasks.named("copyTestJava") {
54+
exclude "**/translation/streaming/**"
55+
}
56+
57+
// Additional supported Spark 4.x versions for compatibility tests.
58+
// Can be expanded as new patch releases are published.
59+
def sparkVersions = [
60+
// "402": "4.0.2", // primary version; already tested via the default build
61+
]
62+
63+
sparkVersions.each { kv ->
64+
configurations.create("sparkVersion$kv.key")
65+
configurations."sparkVersion$kv.key" {
66+
resolutionStrategy {
67+
spark.components.each { component -> force "$component:$kv.value" }
68+
}
69+
}
70+
71+
dependencies {
72+
spark.components.each { component -> "sparkVersion$kv.key" "$component:$kv.value" }
73+
}
74+
75+
tasks.register("sparkVersion${kv.key}Test", Test) {
76+
group = "Verification"
77+
description = "Verifies code compatibility with Spark $kv.value"
78+
classpath = configurations."sparkVersion$kv.key" + sourceSets.test.runtimeClasspath
79+
systemProperties test.systemProperties
80+
81+
include "**/*.class"
82+
maxParallelForks 4
83+
}
84+
}
85+
86+
tasks.register("sparkVersionsTest") {
87+
group = "Verification"
88+
dependsOn sparkVersions.collect{k,v -> "sparkVersion${k}Test"}
89+
}

0 commit comments

Comments
 (0)