fix: Filter compiler plugin options from Scaladoc invocations#1640
Closed
0xRozier wants to merge 1 commit intosbt:developfrom
Closed
fix: Filter compiler plugin options from Scaladoc invocations#16400xRozier wants to merge 1 commit intosbt:developfrom
0xRozier wants to merge 1 commit intosbt:developfrom
Conversation
Scaladoc does not understand compiler plugin options (-Xplugin:, -Xplugin-require:, -P:), causing doc generation to fail when compiler plugins like semanticdb are enabled. Filter these options in AnalyzingCompiler.doc() before passing them to the Scaladoc bridge, fixing the issue for all compiler plugins generically. Fixes sbt/sbt#8740 Co-Authored-By: Claude Opus 4.6 <[email protected]>
eed3si9n
requested changes
Feb 18, 2026
Comment on lines
+474
to
+480
| /** Filter out compiler plugin options not understood by Scaladoc. See sbt/sbt#8740. */ | ||
| private[inc] def filterPluginOptions(options: Seq[String]): Seq[String] = | ||
| options.filterNot { opt => | ||
| opt.startsWith("-Xplugin:") || | ||
| opt.startsWith("-Xplugin-require:") || | ||
| opt.startsWith("-P:") | ||
| } |
Member
There was a problem hiding this comment.
I think without compiler plugins, some files won't compile properly. Could we follow #1545 and substitute the VirtualFileRef instead please?
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.
Summary
-Xplugin:,-Xplugin-require:,-P:) inAnalyzingCompiler.doc()before passing them to the Scaladoc bridgeProblem
When compiler plugins are active (e.g.
semanticdbEnabled := true), their options leak intoscaladocinvocations. Scaladoc does not understand these options and fails with errors like:This was reported in sbt/sbt#8740. The initial fix attempt in sbt/sbt#8760 filtered only semanticdb-specific options in
SemanticdbPlugin, but as @eed3si9n pointed out, this should be fixed at the root cause in Zinc'sAnalyzingCompilerto handle all compiler plugins.Solution
Added
AnalyzingCompiler.filterPluginOptions()that strips compiler plugin options before they reach Scaladoc:-Xplugin:— plugin JAR paths-Xplugin-require:— plugin requirements-P:— plugin-specific optionsThis is similar in spirit to #1545 which also modified
MixedAnalyzingCompilerto processscalacOptions.Test plan
filterPluginOptionscovering all plugin option patternssbt docwithsemanticdbEnabled := trueon Scala 2.12 and 3.xRef sbt/sbt#8740, sbt/sbt#8760
🤖 Generated with Claude Code