[2.x] Opt bspBuildTargetOutputPathsItem out of caching (#9272)

Opt bspBuildTargetOutputPathsItem out of caching
This commit is contained in:
Anatolii Kmetiuk 2026-05-30 00:10:05 +09:00 committed by Eugene Yokota
parent 2ba33f3ff4
commit aed2c6125b
3 changed files with 34 additions and 0 deletions

View File

@ -483,6 +483,7 @@ object Keys {
val bspBuildTargetDependencySources = inputKey[Unit]("").withRank(DTask)
val bspBuildTargetDependencySourcesItem = taskKey[DependencySourcesItem]("").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)

View File

@ -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")
}

View File

@ -0,0 +1,3 @@
> checkProjectA
> set Compile / target := baseDirectory.value / "target-b"
> checkProjectB