⚠️ Versions >= 1.1.2 are built for Intellij IDEA >= 2024.2 and doesn't support the pre-commit feature for Gradle projects due to this bug https://youtrack.jetbrains.com/issue/IDEA-327879
Version 1.1.1 supports the pre-commit check properly but is only compatible with Intellij IDEA 2024.1.* versions.
The Spotless Applier IntelliJ Plugin enhances your development workflow by seamlessly integrating Spotless Gradle and Maven tasks directly within the IntelliJ IDE. With this plugin, you can easily apply code formatting and style enforcement to your projects, either for the current file you're working on or for the entire project.
Actions | Shortcuts (Windows) | Shortcuts (MacOS) |
---|---|---|
Code > Reformat File With Spotless | Ctrl+Alt+; | ⌘Сmd+⌥Opt+; |
Code > Reformat Project With Spotless | Ctrl+Alt+Shift+; | ⌘Сmd+⌥Opt+⇧Shift+; |
✔️ Supports multi-module projects
The plugin offers a commit check to automatically apply Spotless formatting.
To enable this feature, navigate to Settings
> Version Control
> Commit
and activate Reformat code with Spotless
The plugin offers an action to automatically apply Spotless formatting on save. There is an option to choose the file extensions for which it will be triggered.
To enable this feature, navigate to Settings
> Tools
> Actions on Save
and activate Run spotless
To access plugin settings, go to: Settings
> Tools
> Spotless Applier
Prohibit Gradle cache for 'apply' task
> Starting from version 6.6.0, Spotless supports Gradle's configuration cache. If you want to prohibit it, please enable this checkbox.Optimize imports before applying
> Enable this option to additionally execute IntelliJ IDEA's default "optimize imports" task before applying Spotless formatting.
Prohibit imports with asterisk '*'
> Prevents imports with the asterisk symbol during the "optimize imports" task. When enabled, any imports that use the '*' symbol to import all classes from a package will be replaced with FQN.
Settings/Preferences > Plugins > Marketplace > Search for "Spotless Applier" > Install Plugin
Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
This plugin resolve your current build tool by searching the pom.xml
(Maven) or .gradle
(Gradle) files in project's root folder.
After that, it runs the spotless:apply
or spotlessApply
task.
For applying changes only for current file it uses:
Thanks to Ryan Gurney for his Spotless IntelliJ Gradle plugin which I used as the basis for this plugin.
Thanks to Luís Alves for implementing the "Pre-commit check" feature - PR #13.
Thanks to Ertugrul Sener for implementing the "Action on Save" feature - PR #17.
See CONTRIBUTING.md
See CHANGELOG.md
See License