[2.x] fix: Filter semanticdb options from scaladoc invocations#8760
[2.x] fix: Filter semanticdb options from scaladoc invocations#87600xRozier wants to merge 3 commits intosbt:developfrom
Conversation
**Problem** When `semanticdbEnabled := true` is set on Scala 2.x projects, the `doc` task fails because semanticdb-related compiler options (-Xplugin for semanticdb, -P:semanticdb:targetroot, -Yrangepos) are passed to scaladoc, which does not support them. Fixes sbt#8740. **Solution** Add a `doc / scalacOptions` setting in SemanticdbPlugin's configuration settings that filters out semanticdb options from the doc task scope. This removes both the options from `semanticdbOptions` (like -Yrangepos, -P:semanticdb:targetroot for Scala 2.x, and -Xsemanticdb, -semanticdb-target for Scala 3.x) and the -Xplugin flag for the semanticdb compiler plugin. The filtering only applies when `semanticdbEnabled` is true. Generated-by: Claude Opus 4.6 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Generated-by: Claude Opus 4.6 Co-Authored-By: Claude Opus 4.6 <[email protected]>
4716e36 to
fc825f7
Compare
eed3si9n
left a comment
There was a problem hiding this comment.
Thanks. While this approach might work specifically for semanticdb plugin my guess is that it would still be broken for all other compiler plugins until we fix the root cause, which should be fixed in Zinc AnalyzingCompiler similar to sbt/zinc#1545.
|
Thanks for the feedback @eed3si9n! You're right that the fix should be in Zinc to handle all compiler plugins generically, not just semanticdb. I've created a PR against Zinc that filters compiler plugin options ( I've also reverted the semanticdb-specific filtering from |
d8d3ca2 to
fc825f7
Compare
|
Update: I've restored the semanticdb-specific filtering in Once the Zinc fix is merged and the dependency is bumped in sbt, this workaround can be removed since |
Problem
When
semanticdbEnabled := trueis set on Scala 2.x projects, thedoctask fails because semanticdb-related compiler options (-Xplugin:...semanticdb...,-P:semanticdb:targetroot:*,-Yrangepos) leak intodoc / scalacOptions. Scaladoc does not support these options, causing:Fixes #8740.
Solution
Added a
doc / scalacOptionssetting inSemanticdbPlugin.configurationSettingsthat, whensemanticdbEnabledis true, filters out:semanticdbOptions(-Yrangepos,-P:semanticdb:targetroot:*for Scala 2.x;-Xsemanticdb,-semanticdb-targetfor Scala 3.x)-Xplugin:flag containingsemanticdb(the compiler plugin JAR)This is placed in
SemanticdbPluginbecause it introduces these options, so it should be responsible for scoping them away fromdoc.Tests
New scripted test
project/semanticdb-docthat:docon both Scala 2.12 and Scala 3.6 withsemanticdbEnabled := truecompilestill generates.semanticdbfilesAI Disclosure
This PR was created with assistance from Claude Opus 4.6 (AI). All code changes have been reviewed and verified for correctness.
Generated-by: Claude Opus 4.6