Skip to content

Conversation

bjaglin
Copy link
Contributor

@bjaglin bjaglin commented Mar 28, 2025

Fixes #8082

 sbt:sbt-test> inspect compileIncremental
 [info] Task: class scala.Tuple3
 [info] Description:
 [info] 	Actually runs the incremental compilation
 [info] Provided by:
 [info] 	ProjectRef(uri("file:/private/tmp/sbt-test/"), "sbt-test") / Compile / compileIncremental
 [info] Defined at:
 [info] 	(TaskZero / compileIncremental) := {
 [info]         val bspTask = (compile / bspCompileTask).value
 [info]         val result = cachedCompileIncrementalTask.result.value
 [info]         val reporter = (compile / bspReporter).value
 [info]         val store = analysisStore(compileAnalysisFile)
 [info]         val ci = (compile / compileInputs).value
 [info]         val c = fileConverter.value
 [info]         val dir = c.toPath(backendOutput.value).toFile
 [info]         result match
 [info]           case Result.Value(res) =>
 [info]             val analysis = store.unsafeGet().getAnalysis()
 [info]             reporter.sendSuccessReport(analysis)
 [info]             bspTask.notifySuccess(analysis)
 [info]             res
 [info]           case Result.Inc(cause) =>
 [info]             val compileFailed = cause.directCause.collect { case c: CompileFailed => c }
 [info]             reporter.sendFailureReport(ci.options.sources)
 [info]             bspTask.notifyFailure(compileFailed)
 [info]             throw cause
 [info]       }:2143
+[info] 	compileIncremental := Def.taskIf {
+[info]       if (!semanticdbEnabled.value) compileIncremental.value
+[info]       else compileIncrementalWithCachedSemanticdbTask.value
+[info]     }.value:57
 sbt:sbt-test> inspect tree compileIncremental
 [info] Compile / compileIncremental = Task[class scala.Tuple3]
 [info]   +-Compile / compile / bspCompileTask = Task[class sbt.internal.server.BspCom..
 ...
 [info]   +-Compile / backendOutput = ${OUT}/jvm/scala-3.6.4/sbt-test/backend
 [info]   +-Compile / compileAnalysisFile = Task[class java.io.File]
 [info]   +-Global / fileConverter = sbt.internal.inc.MappedFileConverter@26582ca
 [info]   +-Global / state = Task[class sbt.State]
 [info]   +-Compile / compileIncremental / streams = Task[interface sbt.std.TaskStreams]
 [info]   | +-Global / streamsManager = Task[interface sbt.std.Streams]
 [info]   |
 [info]   +-Compile / earlyOutputPing = Task[class sbt.PromiseWrap]
+[info]   +-Global / fileConverter = sbt.internal.inc.MappedFileConverter@26582ca
+[info]   +-Global / semanticdbEnabled = false
+[info]   +-Compile / semanticdbTargetRoot = target/out/jvm/scala-3.6.4/sbt-test/meta
+[info]   | +-Compile / backendOutput = ${OUT}/jvm/scala-3.6.4/sbt-test/backend
+[info]   | | +-Compile / configuration = compile
+[info]   | | +-Global / fileConverter = sbt.internal.inc.MappedFileConverter@26582ca
+[info]   | | +-target = target/out/jvm/scala-3.6.4/sbt-test
+[info]   | |
+[info]   | +-Compile / configuration = compile
+[info]   | +-Global / fileConverter = sbt.internal.inc.MappedFileConverter@26582ca
+[info]   | +-Global / semanticdbIncludeInJar = false
+[info]   | +-target = target/out/jvm/scala-3.6.4/sbt-test
+[info]   |
+[info]   +-Global / state = Task[class sbt.State]

@bjaglin bjaglin force-pushed the cache-semanticdb branch 4 times, most recently from 6b952d7 to 04abad9 Compare March 28, 2025 11:43
@@ -5,7 +5,7 @@ lazy val expectErrorNotCrash = taskKey[Unit]("Ensures that sbt properly set type

expectErrorNotCrash := {
val fail = (Compile / compileIncremental).failure.value
fail.directCause match
Incomplete.allExceptions(fail).headOption match
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Def.taskIf wrapping introduces an indirection ... I assume it's OK as user shouldn't rely on the exact hierarchy since plugins may change it anyway.

Comment on lines +12 to +13
> set LocalProject("matrix2_12") / Compile / semanticdbTargetRoot := (LocalProject("matrix2_12") / Compile / target).value / "custom212"
> set LocalProject("matrix3") / Compile / semanticdbTargetRoot := (LocalProject("matrix3") / Compile / target).value / "custom3"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I ended up using that syntax because

  • bare settings don't work with set
  • matrix projects can't be addressed by their name (but only by their ID??)

@eed3si9n
Copy link
Member

nice. thanks for the contribution! I'm afk now but I'll check out the impl as soon as I can.

Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit 187eb0f into sbt:develop Mar 30, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants