From c70b86d5c9711ae0e4bd402ba29610d416ea1c75 Mon Sep 17 00:00:00 2001 From: Anatolii Kmetiuk Date: Sat, 30 May 2026 00:10:05 +0900 Subject: [PATCH] [2.x] Opt bspBuildTargetOutputPathsItem out of caching (#9272) Opt bspBuildTargetOutputPathsItem out of caching --- main/src/main/scala/sbt/Keys.scala | 1 + .../server/bsp-output-paths-cache/build.sbt | 30 +++++++++++++++++++ .../server/bsp-output-paths-cache/test | 3 ++ 3 files changed, 34 insertions(+) create mode 100644 sbt-app/src/sbt-test/server/bsp-output-paths-cache/build.sbt create mode 100644 sbt-app/src/sbt-test/server/bsp-output-paths-cache/test diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 44dad99ad..b3a106662 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -487,6 +487,7 @@ object Keys { val bspBuildTargetDependencyModules = inputKey[Unit]("").withRank(DTask) val bspBuildTargetDependencyModulesItem = taskKey[DependencyModulesItem]("").withRank(DTask) val bspBuildTargetOutputPaths = inputKey[Unit]("").withRank(DTask) + @transient val bspBuildTargetOutputPathsItem = taskKey[OutputPathsItem]("").withRank(DTask) val bspBuildTargetCompile = inputKey[Unit]("").withRank(DTask) val bspBuildTargetCompileItem = taskKey[Int]("").withRank(DTask) diff --git a/sbt-app/src/sbt-test/server/bsp-output-paths-cache/build.sbt b/sbt-app/src/sbt-test/server/bsp-output-paths-cache/build.sbt new file mode 100644 index 000000000..670303fad --- /dev/null +++ b/sbt-app/src/sbt-test/server/bsp-output-paths-cache/build.sbt @@ -0,0 +1,30 @@ +import sbt.internal.bsp.OutputPathsItem + +ThisBuild / scalaVersion := "3.8.2" + +name := "bsp-output-paths-cache" + +Compile / target := baseDirectory.value / "target-a" + +@transient +lazy val checkProjectA = taskKey[Unit]("") + +@transient +lazy val checkProjectB = taskKey[Unit]("") + +def checkOutputPath(item: OutputPathsItem, expectedSegment: String): Unit = { + val actual = item.outputPaths.map(_.uri.toString).mkString("\n") + if (!actual.contains(expectedSegment)) { + sys.error( + s"stale bspBuildTargetOutputPathsItem: expected segment $expectedSegment in output paths, got: $actual" + ) + } +} + +checkProjectA := Def.uncached { + checkOutputPath((Compile / bspBuildTargetOutputPathsItem).value, "target-a") +} + +checkProjectB := Def.uncached { + checkOutputPath((Compile / bspBuildTargetOutputPathsItem).value, "target-b") +} diff --git a/sbt-app/src/sbt-test/server/bsp-output-paths-cache/test b/sbt-app/src/sbt-test/server/bsp-output-paths-cache/test new file mode 100644 index 000000000..e82347dd6 --- /dev/null +++ b/sbt-app/src/sbt-test/server/bsp-output-paths-cache/test @@ -0,0 +1,3 @@ +> checkProjectA +> set Compile / target := baseDirectory.value / "target-b" +> checkProjectB