Switch formatter to forked google-java-format CLI in dedicated JVM#264
Merged
Switch formatter to forked google-java-format CLI in dedicated JVM#264
Conversation
Member
Author
|
This gets launched now when calling java formatter: This is what Here you can see So the classpath is the same as from the sbt session you are currently in. However that does not matter as only classes get loaded that the google formatter really needs. |
This was referenced Apr 15, 2026
mkurz
added a commit
to mkurz/playframework
that referenced
this pull request
Apr 15, 2026
- google-java-format runs in its CLI in dedicated JVM now - sbt/sbt-java-formatter#264
mkurz
commented
Apr 15, 2026
| if (!options.reorderModifiers()) { | ||
| throw new MessageOnlyException( | ||
| "The forked google-java-format CLI does not support reorderModifiers = false. " + | ||
| "Please use the default reorderModifiers setting.") |
Member
Author
There was a problem hiding this comment.
This was referenced Apr 15, 2026
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.
sbt-java-formatter-add-opensplugin #261. The separatesbt-java-formatter-add-opensplugin/artifact is no longer needed.Instead of wrapping sbt commands in another sbt process, the plugin now solves the underlying problem directly by running
google-java-formatin its own JVM with the requiredjdk.compileraccess flags.This uses the
google-java-formatCLI rather than the in-process library call, so formatter execution also works whenjavafmtis triggered indirectly, for example viajavafmtOnCompile.Before, formatting happened in-process via:
Now the plugin launches a separate java process and invokes the google-java-format CLI with the required module flags.
From a user perspective, this is now transparent: no matter how javafmt gets invoked, the formatter runs in a JVM with the required flags. In particular, this fixes the
javafmtOnCompile/ task-dependency case that the previous wrapper-based approach could not handle reliably because it just created alias for the commands.