Get easy look-alike readable code with IntelliJ
Spotless is are really cool tool for formatting your code with build tools. If you like, you can do that with your IDE too. I show your how to configure IntelliJ, so your code is automatically formatted while you save a file.
First you have to install the Google Java Format Plugin. After that please install the Save Action Plugin. Now go to File→Settings→Other Settings→Save Action and activate „Activate save action on save“. Activate the Formating Actions „Optimize imports“ and „Reformate File“ too.
Check the google-java-format setting, if the plugin is enabled. Unfortunately the import ordering is not handled by this plugin. To fix the import order, download the IntelliJ Java Google Style file and import it into File→Settings→Editor→Code Style.
That’s it. Happy coding.
Links
Spotless Gradle Plugin https://github.com/diffplug/spotless/tree/master/plugin-gradle
IntelliJ Google Java Format Plugin https://plugins.jetbrains.com/plugin/8527-google-java-format
IntelliJ Save Action Plugin https://plugins.jetbrains.com/plugin/7642-save-actions
IntelliJ Java Google Style file https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml