You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDEA-180965: Add support for IntelliJ formatter #200
The line wrapping options that can be configured with IntelliJ seem to be a little bit more flexible than the one available in Eclipse (e.g. lambda-related preferences).
The closest thing I've found to format Java sources using an IntelliJ code style is its command line formatter. Although that still requires having the full binaries of IntelliJ (but I hope to be wrong!).
Reacted by Tomas R, Feng Yu, Ruth, mdbarr73, Arnaldo Trujillo Falcón, Eric Sirianni, Alex Stark, Mikołaj Kondratek, Andrei Sfat, Jonathan Bluett-Duncan and 42 more
changed the title [-][QUESTION] Is there any plan to support IntelliJ generated code style for Java?[/-][+]Add support for IntelliJ formatter[/+]on Feb 8, 2018
If you don't care about using the IntelliJ formatter specifically, but rather just the IntelliJ IDE to autoformat in a way that agrees with Spotless, another path forward would be to make a plugin for IntelliJ that calls out to the spotless IDE hook. For example, here's a plugin for VSCode.
Reacted by Vishal Nehra, Michael Leonhard and DanielPinoGL
A PR for this would be very welcome. ForeignExe might be the easiest way to implement it. It's okay if it only works on some platforms, so long as it works for the platform you use. Future PR's can always add support for missing platforms.
I created the *Step class a few days ago. It works fine on my macos machine. I faced a problem testing it on CI, there is no IDEA binary & simple installation from brew might require tweaking.
I saw your PR #672. Maybe I'm missing something but I don't have any good ideas on running IDEA in test on every machine (CI at least). I can come up with a solution but maybe the team has an appropriate solution for the problem.
note that all tests have @GofmtTest from the tag above
In this way, the tests are always compiled, even though they aren't run.
Of all these "special" tests, the only ones which get run on CI right now are the npm tests. It would be better if they all ran, but it would be worse if the steps didn't exist at all.
The important thing is that if someone wants to develop the step further, they aren't starting from scratch - they have tests, they just need to setup their local machine to have foreign exe in question.
Reacted by Daniel Kraus, Ilya Ilyinykh and Clif Reeder
I am excited about this feature!! I hope it makes it to main sometime! On a new project i ended up using the eclipse formatter because of the customizability, but most of us use IntelliJ so this would be a huge win!!
@simschla Thank you! Our team is looking into creating a pre-commit hook using Intellij style, so far only Spotless with Intellij formatter seems to be a promising solution.
Activity
nedtwigg commentedon Feb 8, 2018
Happy to merge a PR for this, but currently nobody is working on it.
You can use a custom step do this, there's an example of how to do this (and a description of its shortcomings) in #119.
[-][QUESTION] Is there any plan to support IntelliJ generated code style for Java?[/-][+]Add support for IntelliJ formatter[/+]fabriziocucci commentedon Feb 12, 2018
Commented interesting issue on the IntelliJ issue tracker related to this enhancement:
https://youtrack.jetbrains.com/issue/IDEA-180965
[-]Add support for IntelliJ formatter[/-][+]IDEA-180965: Add support for IntelliJ formatter[/+]leonard84 commentedon Sep 14, 2018
Also: Provide standalone formatter or API https://youtrack.jetbrains.com/issue/IDEABKL-7685
nedtwigg commentedon Jun 3, 2020
If you don't care about using the IntelliJ formatter specifically, but rather just the IntelliJ IDE to autoformat in a way that agrees with Spotless, another path forward would be to make a plugin for IntelliJ that calls out to the spotless IDE hook. For example, here's a plugin for VSCode.
anandbhaskaran commentedon Jun 8, 2020
It would be awesome if this come into reality!
lfgcampos commentedon Jan 6, 2021
Long shot but, any news about it?
sbilello commentedon Sep 30, 2021
If we want to use the intellij java code style with spotless. What's the recommended approach? https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml
jbduncan commentedon Oct 2, 2021
@sbilello Spotless doesn't support the IntelliJ formatter yet. The way to get Google-style Java formatting is to use this instruction:
It uses google-java-format, which is a successor to the IntelliJ XML file you linked, so I recommend google-java-format over it. :)
11 remaining items
nedtwigg commentedon Jun 8, 2023
Nope, we just got PR's from Gradle users, that's all.
lipiridi commentedon Aug 12, 2023
@ragurney @lutovich @tonjohn @nedtwigg
Hi! I've been developed a plugin that supports maven based on @ragurney's plugin (for which special thanks to him) and added some new features.
https://plugins.jetbrains.com/plugin/22455-spotless-applier
https://github.com/lipiridi/spotless-applier
IlyasYOY commentedon Nov 2, 2023
Hello! Any updates on the issue?
I found docs: Format files from the command line | IntelliJ IDEA Documentation.
I use this API myself to format code using neovim:
I'd be glad to try to implement the feature if maintainers think it's possible.
PS. I tested this on Linux & MacOS. There some caveats:
Anyway considering all above, I'd gave a try to the feature. I'd add this as experimental due to unstable API of the IDE.
nedtwigg commentedon Nov 9, 2023
A PR for this would be very welcome.
ForeignExemight be the easiest way to implement it. It's okay if it only works on some platforms, so long as it works for the platform you use. Future PR's can always add support for missing platforms.IlyasYOY commentedon Jan 16, 2024
Thanks for your hint @nedtwigg
I created the
*Stepclass a few days ago. It works fine on my macos machine. I faced a problem testing it on CI, there is no IDEA binary & simple installation from brew might require tweaking.I saw your PR #672. Maybe I'm missing something but I don't have any good ideas on running IDEA in test on every machine (CI at least). I can come up with a solution but maybe the team has an appropriate solution for the problem.
Contribution guide helped a lot, thanks!
nedtwigg commentedon Jan 23, 2024
Amazing!
IdeaStephas been implemented, after half a decade in the desert!Note the following:
gofmt#2001@GofmtTestfrom the tag aboveIn this way, the tests are always compiled, even though they aren't run.
Of all these "special" tests, the only ones which get run on CI right now are the npm tests. It would be better if they all ran, but it would be worse if the steps didn't exist at all.
The important thing is that if someone wants to develop the step further, they aren't starting from scratch - they have tests, they just need to setup their local machine to have foreign exe in question.
Make IDEA tests special
IlyasYOY commentedon Jan 23, 2024
Thanks for the advice! Really appreciate it!
I've just opened a Draft PR.
#2020
CC007 commentedon Dec 6, 2024
Any info on getting this to work with maven? Spotless applier is a nice first attempt, but is too slow for my use-case.
zlsmith86 commentedon Feb 10, 2025
I am excited about this feature!! I hope it makes it to main sometime! On a new project i ended up using the eclipse formatter because of the customizability, but most of us use IntelliJ so this would be a huge win!!
simschla commentedon Feb 21, 2025
I'm working on this (based on #2020) because I would love to have it too. Can't make any promises on the timeline, though.
jimmyzzxhlh commentedon Feb 28, 2025
@simschla Thank you! Our team is looking into creating a pre-commit hook using Intellij style, so far only Spotless with Intellij formatter seems to be a promising solution.
simschla commentedon Jul 2, 2025
Resolved in #2535
nedtwigg commentedon Jul 7, 2025
Released in
plugin-gradle 7.1.0andplugin-maven 2.45.0.