-
Notifications
You must be signed in to change notification settings - Fork 484
Add docs for Maven IDE hook #2573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Spotless Maven IDE integrations | ||
|
||
## How to add an IDE | ||
|
||
The Spotless plugin for Maven accepts a command-line argument `-DspotlessIdeHook=${ABSOLUTE_PATH_TO_FILE}`. In this mode, `spotless:check` is disabled, and `spotless:apply` will apply only to that one file. Because it already knows the absolute path of the only file you are asking about, it is able to run much faster than a normal invocation of `spotless:apply`. | ||
|
||
For extra flexibility, you can add `-DspotlessIdeHookUseStdIn`, and Spotless will read the file content from `stdin`. This allows you to send the content of a dirty editor buffer without writing to a file. You can also add `-DspotlessIdeHookUseStdOut`, and Spotless will return the formatted content on `stdout` rather than writing it to a file (you should also add `--quiet` to make sure Maven doesn't dump logging info into `stdout`). | ||
|
||
In all of these cases, Spotless will send useful status information on `stderr`: | ||
|
||
- if `stderr` starts with `IS DIRTY`, then the file was dirty, and `stdout` contains its full formatted contents | ||
- in every other case, `stdout` will be empty / the file will be unchanged because there is nothing to change | ||
- if `stderr` starts with `IS CLEAN`, then the file is already clean | ||
- if `stderr` starts with `DID NOT CONVERGE`, then the formatter is misbehaving, and the rest of `stderr` has useful diagnostic info (e.g. `spotless:diagnose` for [padded cell](../PADDEDCELL.md)) | ||
- if `stderr` is empty, then the file is not being formatted by spotless (not included in any target) | ||
- if `stderr` is anything else, then it is the stacktrace of whatever went wrong |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference to
spotless:diagnose
appears to be Gradle-specific syntax. For Maven, this should likely bemvn spotless:diagnose
to be consistent with Maven command syntax.Copilot uses AI. Check for mistakes.