Skip to content

Deduplicate Java runtime mismatch hints per formatter invocation#283

Merged
mkurz merged 1 commit intosbt:mainfrom
mkurz:reset-runtime-hint-per-invocation
Apr 16, 2026
Merged

Deduplicate Java runtime mismatch hints per formatter invocation#283
mkurz merged 1 commit intosbt:mainfrom
mkurz:reset-runtime-hint-per-invocation

Conversation

@mkurz
Copy link
Copy Markdown
Member

@mkurz mkurz commented Apr 16, 2026

Summary

This adjusts the Java runtime mismatch hint deduplication logic so it is scoped to a single formatter invocation, instead of effectively sticking for the whole sbt session.

Problem

After

the hint was logged only once per project, which reduced the noise during a single javafmtAll run.

However, that also meant that if a user stayed in the same sbt session and ran javafmtAll again later, the hint would no longer be shown at all for projects that had already logged it once before.

That is not what we want. The hint should be deduplicated within one formatter run, but it should appear again for a later independent run.

Change

Instead of resetting mutable state at task entry, this PR introduces an internal formatter invocation id:

  • each javafmt, javafmtCheck, javafmtFixImports, and javafmtFixImportsCheck invocation gets a fresh internal id
  • the runtime mismatch hint cache now stores the last invocation id per project
  • the hint is emitted once per project per invocation id

This keeps the good behavior from #282:

  • javafmtAll does not spam the same hint repeatedly within one run

while restoring the missing behavior:

  • running javafmtAll again later in the same sbt session shows the hint again

User-visible behavior

With an incompatible formatter JVM:

  • one javafmtAll run logs the hint once per affected project
  • a second javafmtAll run in the same sbt session logs the hint again
  • direct javafmt / javafmtCheck runs also behave the same way

Verification

Tested locally by publishing the plugin and reproducing the behavior in a multi-project build:

  • first javafmtAll run: hint shown once per affected project
  • second javafmtAll run in the same sbt session: hint shown again

@mkurz mkurz merged commit 3f61339 into sbt:main Apr 16, 2026
5 checks passed
@mkurz mkurz deleted the reset-runtime-hint-per-invocation branch April 16, 2026 20:10
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.

1 participant