Skip to content

fix: Filter compiler plugin options from Scaladoc invocations#1640

Closed
0xRozier wants to merge 1 commit intosbt:developfrom
0xRozier:fix/scaladoc-filter-plugin-options
Closed

fix: Filter compiler plugin options from Scaladoc invocations#1640
0xRozier wants to merge 1 commit intosbt:developfrom
0xRozier:fix/scaladoc-filter-plugin-options

Conversation

@0xRozier
Copy link
Copy Markdown

@0xRozier 0xRozier commented Feb 18, 2026

Summary

  • Filter out compiler plugin options (-Xplugin:, -Xplugin-require:, -P:) in AnalyzingCompiler.doc() before passing them to the Scaladoc bridge
  • Fixes the root cause of scaladoc failures when compiler plugins (like semanticdb) are enabled
  • Handles all compiler plugins generically, not just semanticdb

Problem

When compiler plugins are active (e.g. semanticdbEnabled := true), their options leak into scaladoc invocations. Scaladoc does not understand these options and fails with errors like:

bad option: '-Xplugin:/path/to/semanticdb-scalac.jar'

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's AnalyzingCompiler to 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 options

This is similar in spirit to #1545 which also modified MixedAnalyzingCompiler to process scalacOptions.

Test plan

  • Unit tests for filterPluginOptions covering all plugin option patterns
  • Integration: sbt doc with semanticdbEnabled := true on Scala 2.12 and 3.x

Ref sbt/sbt#8740, sbt/sbt#8760

🤖 Generated with Claude Code

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]>
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:")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think without compiler plugins, some files won't compile properly. Could we follow #1545 and substitute the VirtualFileRef instead please?

@0xRozier 0xRozier closed this by deleting the head repository Apr 2, 2026
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