Skip to content

Commit cb76c66

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]> (cherry picked from commit eec092c) Signed-off-by: Wenchen Fan <[email protected]>
1 parent fb13ecd commit cb76c66

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
@@ -1225,8 +1225,15 @@ object ExcludedDependencies {
12251225
* client dependencies.
12261226
*/
12271227
object ExcludeShims {
1228+
import bloop.integrations.sbt.BloopKeys
1229+
12281230
val shimmedProjects = Set("spark-sql-api", "spark-connect-common", "spark-connect-client-jdbc", "spark-connect-client-jvm")
12291231
val classPathFilter = TaskKey[Classpath => Classpath]("filter for classpath")
1232+
1233+
// Filter for bloopInternalClasspath which is Seq[(File, File)]
1234+
type BloopClasspath = Seq[(java.io.File, java.io.File)]
1235+
val bloopClasspathFilter = TaskKey[BloopClasspath => BloopClasspath]("filter for bloop classpath")
1236+
12301237
lazy val settings = Seq(
12311238
classPathFilter := {
12321239
if (!shimmedProjects(moduleName.value)) {
@@ -1235,6 +1242,16 @@ object ExcludeShims {
12351242
identity _
12361243
}
12371244
},
1245+
bloopClasspathFilter := {
1246+
if (!shimmedProjects(moduleName.value)) {
1247+
// Note: bloop output directories use "connect-shims" (without "spark-" prefix)
1248+
cp => cp.filterNot { case (f1, f2) =>
1249+
f1.getPath.contains("connect-shims") || f2.getPath.contains("connect-shims")
1250+
}
1251+
} else {
1252+
identity _
1253+
}
1254+
},
12381255
Compile / internalDependencyClasspath :=
12391256
classPathFilter.value((Compile / internalDependencyClasspath).value),
12401257
Compile / internalDependencyAsJars :=
@@ -1247,6 +1264,13 @@ object ExcludeShims {
12471264
classPathFilter.value((Test / internalDependencyClasspath).value),
12481265
Test / internalDependencyAsJars :=
12491266
classPathFilter.value((Test / internalDependencyAsJars).value),
1267+
// Filter bloop's internal classpath for correct IDE integration
1268+
Compile / BloopKeys.bloopInternalClasspath :=
1269+
bloopClasspathFilter.value((Compile / BloopKeys.bloopInternalClasspath).value),
1270+
Runtime / BloopKeys.bloopInternalClasspath :=
1271+
bloopClasspathFilter.value((Runtime / BloopKeys.bloopInternalClasspath).value),
1272+
Test / BloopKeys.bloopInternalClasspath :=
1273+
bloopClasspathFilter.value((Test / BloopKeys.bloopInternalClasspath).value),
12501274
)
12511275
}
12521276

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)