How to run ReformatCodeProcess headless?
I feel like I've nearly got this - in fact, sometimes it works! However, there's obviously a race condition somewhere that means the files aren't getting written sometimes.
Here's a gist of what I have so far: https://gist.githubusercontent.com/marcosscriven/3badfb3001d7e18aa668/raw/7e4184fcb6f4e5183b55c989b62693c40568168d/CodeFormatter.java
Note, I extended IdeaApplication, only so I could set an ApplicationStater, without having to define a plugin just to add dynamically to the 'appStarter' extension point.
Please sign in to leave a comment.
For posterity, I got this working, but it was fairly hacky. I had to manually run imports and set things up in exactly the same order as the IDE does automatically.
I was looking for a solution to run the formatter headless as well. Especially for Continuous Integration. You can run the formatter from the terminal now.
https://confluence.jetbrains.com/display/IDEADEV/Command-Line+Source+Code+Formatter
Robert, does it work for you?
This page seems to refer to the format.sh script which is not yet released. At least there is no such script in official tarball I've downloaded from site
JetBrains people, please update the page with versioning information, it becomes extremely confusing otherwise
You're right
The current version is IC-162.2228.15 which doesn't have the format.sh script available yet.
I'm using the next version of IntelliJ, IC-163.6512.17, https://www.jetbrains.com/idea/nextversion