[2.x] fix: Resolve virtual file refs in scaladoc options#8768
Merged
eed3si9n merged 1 commit intosbt:developfrom Feb 20, 2026
Merged
[2.x] fix: Resolve virtual file refs in scaladoc options#8768eed3si9n merged 1 commit intosbt:developfrom
eed3si9n merged 1 commit intosbt:developfrom
Conversation
When `semanticdbEnabled := true` is set on Scala 2.x projects, the
`doc` task fails because `${CSR_CACHE}` placeholders in scalacOptions
(specifically the `-Xplugin:` path for the semanticdb compiler plugin)
are not resolved before being passed to Scaladoc.
This fix resolves virtual file references (containing $) in
scalacOptions before passing them to the Scaladoc bridge, matching
what zinc's MixedAnalyzingCompiler already does for compilation
(see sbt/zinc#1545).
Fixes sbt#8740
Generated-by: GitHub Copilot (Claude Opus 4.6)
eed3si9n
approved these changes
Feb 20, 2026
Member
eed3si9n
left a comment
There was a problem hiding this comment.
Thanks for the contribution. lgtm pending CI.
Contributor
Author
Thanks for approving my PR. Seems CI passed successfully. |
eed3si9n
reviewed
Feb 20, 2026
Comment on lines
+2067
to
+2073
| def convertVfRef(value: String): String = | ||
| if !value.contains("$") then value | ||
| else converter.toPath(VirtualFileRef.of(value)).toString | ||
| val resolvedOptions = options.map { x => | ||
| if !x.contains("$") then x | ||
| else x.split(":").map(_.split(",").map(convertVfRef).mkString(",")).mkString(":") | ||
| } |
Member
There was a problem hiding this comment.
Ideally, this should be pushed to Zinc, but I'm fine with this workaround for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #8740
When
semanticdbEnabled := trueis set on Scala 2.x projects, thedoctask fails because${CSR_CACHE}placeholders inscalacOptions(specifically the-Xplugin:path for the semanticdb compiler plugin JAR) are not resolved before being passed to Scaladoc. This causes:The root cause is that the plugin JAR path contains an unresolved
${CSR_CACHE}variable, so the plugin fails to load, and its associated-P:semanticdb:*flags are rejected as unknown options.Reproduction (from #8740)
Solution
Resolve virtual file references (containing
$) inscalacOptionsbefore passing them to the Scaladoc bridge indocTaskSettings. This matches the approach already used in zinc'sMixedAnalyzingCompiler.compileScala()(see sbt/zinc#1545), which resolves$variables for compilation but not for doc generation.The resolution splits each option by
:and,, then converts any part containing$viaVirtualFileRef.of() -> converter.toPath().Tests
project/semanticdb-docscripted test: runsdocon a Scala 2.12 project withsemanticdbEnabled := trueproject/*,actions/*,compiler-project/*scripted test suites locally — all passAI Disclosure
This PR was developed with assistance from GitHub Copilot (Claude Opus 4.6). All code changes, test design, and debugging were AI-assisted.
Generated-by: GitHub Copilot (Claude Opus 4.6)