Skip to content

Commit eec092c

Browse files
committed
[SPARK-54851][BUILD] Support generating bloop files via sbt
### What changes were proposed in this pull request? Some IDEs such as cursor/VSCode works better with bloop as the build server. This PR supports generating the bloop config files via sbt. ### Why are the changes needed? better IDE support ### Does this PR introduce _any_ user-facing change? no, dev only ### How was this patch tested? manual test ### Was this patch authored or co-authored using generative AI tooling? cursor 2.2.43 Closes #53621 from cloud-fan/bloop. Lead-authored-by: Wenchen Fan <[email protected]> Co-authored-by: Wenchen Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
1 parent 174b62d commit eec092c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

project/SparkBuild.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,15 @@ object ExcludedDependencies {
12281228
* client dependencies.
12291229
*/
12301230
object ExcludeShims {
1231+
import bloop.integrations.sbt.BloopKeys
1232+
12311233
val shimmedProjects = Set("spark-sql-api", "spark-connect-common", "spark-connect-client-jdbc", "spark-connect-client-jvm")
12321234
val classPathFilter = TaskKey[Classpath => Classpath]("filter for classpath")
1235+
1236+
// Filter for bloopInternalClasspath which is Seq[(File, File)]
1237+
type BloopClasspath = Seq[(java.io.File, java.io.File)]
1238+
val bloopClasspathFilter = TaskKey[BloopClasspath => BloopClasspath]("filter for bloop classpath")
1239+
12331240
lazy val settings = Seq(
12341241
classPathFilter := {
12351242
if (!shimmedProjects(moduleName.value)) {
@@ -1238,6 +1245,16 @@ object ExcludeShims {
12381245
identity _
12391246
}
12401247
},
1248+
bloopClasspathFilter := {
1249+
if (!shimmedProjects(moduleName.value)) {
1250+
// Note: bloop output directories use "connect-shims" (without "spark-" prefix)
1251+
cp => cp.filterNot { case (f1, f2) =>
1252+
f1.getPath.contains("connect-shims") || f2.getPath.contains("connect-shims")
1253+
}
1254+
} else {
1255+
identity _
1256+
}
1257+
},
12411258
Compile / internalDependencyClasspath :=
12421259
classPathFilter.value((Compile / internalDependencyClasspath).value),
12431260
Compile / internalDependencyAsJars :=
@@ -1250,6 +1267,13 @@ object ExcludeShims {
12501267
classPathFilter.value((Test / internalDependencyClasspath).value),
12511268
Test / internalDependencyAsJars :=
12521269
classPathFilter.value((Test / internalDependencyAsJars).value),
1270+
// Filter bloop's internal classpath for correct IDE integration
1271+
Compile / BloopKeys.bloopInternalClasspath :=
1272+
bloopClasspathFilter.value((Compile / BloopKeys.bloopInternalClasspath).value),
1273+
Runtime / BloopKeys.bloopInternalClasspath :=
1274+
bloopClasspathFilter.value((Runtime / BloopKeys.bloopInternalClasspath).value),
1275+
Test / BloopKeys.bloopInternalClasspath :=
1276+
bloopClasspathFilter.value((Test / BloopKeys.bloopInternalClasspath).value),
12531277
)
12541278
}
12551279

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.17.0")
4646
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")
4747

4848
addSbtPlugin("com.here.platform" % "sbt-bom" % "1.0.29")
49+
50+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.17")

0 commit comments

Comments
 (0)