Skip to content

[2.x] fix: Respect last plugin toggle for enablePlugins/disablePlugins#8794

Merged
eed3si9n merged 1 commit intosbt:developfrom
it-education-md:fix/i1926-disable-enable-plugin-precedence
Feb 23, 2026
Merged

[2.x] fix: Respect last plugin toggle for enablePlugins/disablePlugins#8794
eed3si9n merged 1 commit intosbt:developfrom
it-education-md:fix/i1926-disable-enable-plugin-precedence

Conversation

@it-education-md
Copy link
Copy Markdown
Contributor

Closes #1926

Problem

Calling disablePlugins(X).enablePlugins(X) (or the reverse order) could leave both include and exclude for the same plugin in the selected plugin expression, which caused AutoPluginException contradiction during project load/reload.

Solution

Introduce explicit toggle precedence (last call wins) when combining plugin selections:

  • disable -> enable keeps plugin enabled
  • enable -> disable keeps plugin disabled

Apply the same behavior to both Project and ProjectMatrix.

Testing

  • Reproduced with scripted test setup in sbt-app/src/sbt-test/project/i1926-disable-enable-plugin
  • Added unit coverage in main/src/test/scala/ProjectSpec.scala
  • Verified locally:
    • sbt "mainProj/testOnly sbt.ProjectSpec"
    • sbt "scripted project/i1926-disable-enable-plugin"

…sbt#1926)

Treat explicit plugin toggles as last-call-wins for the same plugin.
This avoids contradictory include/exclude states when disablePlugins(X) is followed by
enablePlugins(X) (and vice versa), aligning behavior with normal override expectations.

Apply the same semantics to ProjectMatrix and add regression coverage:
- unit tests in main/src/test/scala/ProjectSpec.scala
- scripted test in sbt-app/src/sbt-test/project/i1926-disable-enable-plugin
@it-education-md
Copy link
Copy Markdown
Contributor Author

@eed3si9n please review my PR. thank you.

Copy link
Copy Markdown
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 cb498de into sbt:develop Feb 23, 2026
15 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.

No way to enable plugin after it was disabled

2 participants