Skip to content

Commit 3ccaa5b

Browse files
committed
workaround bug on builds handled by sbt 2.0.0-M4
1 parent e2a17b4 commit 3ccaa5b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pluginCrossBuild / sbtVersion := {
5454
case "2.12" =>
5555
"1.4.0"
5656
case _ =>
57+
// remove SemanticdbCachingWorkaroundPlugin when bumping
5758
"2.0.0-M4" // bin/test-release.sh
5859
}
5960
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sbt.*
2+
import sbt.Keys.*
3+
import sbt.plugins.JvmPlugin
4+
import sbt.util.CacheImplicits.given
5+
6+
// https://github.com/sbt/sbt/pull/8086
7+
object SemanticdbCachingWorkaroundPlugin extends AutoPlugin {
8+
9+
override def trigger: PluginTrigger = allRequirements
10+
override def requires: Plugins = JvmPlugin
11+
12+
override lazy val projectSettings: Seq[Def.Setting[?]] =
13+
Seq(Compile, Test).flatMap(c =>
14+
inConfig(c)(
15+
compileIncremental := Def.taskIf {
16+
if (semanticdbIncludeInJar.value || !semanticdbEnabled.value)
17+
compileIncremental.value
18+
else compileIncAndCacheSemanticdbTargetRootTask.value
19+
}.value
20+
)
21+
)
22+
23+
private val compileIncAndCacheSemanticdbTargetRootTask = Def.cachedTask {
24+
val prev = compileIncremental.value
25+
val converter = fileConverter.value
26+
val targetRoot = semanticdbTargetRoot.value
27+
28+
val vfTargetRoot = converter.toVirtualFile(targetRoot.toPath)
29+
Def.declareOutputDirectory(vfTargetRoot)
30+
prev
31+
}
32+
}

0 commit comments

Comments
 (0)