lipiridi / spotless-applier

An IntelliJ plugin that allows running the spotless Gradle and Maven tasks from within the IDE, either on the current file selected in the editor or for the whole project.
MIT License
21 stars 2 forks source link
formatter gradle intellij intellij-plugin maven plugin spotless

Spotless Applier

Build Version Downloads

⚠️ Version 1.1.2 is 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.

Features

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

Commit check

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

Action on save

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

Settings

To access plugin settings, go to: Settings > Tools > Spotless Applier

Media

spotlessdemo image image image

Install

Using IDE built-in plugin system:

Settings/Preferences > Plugins > Marketplace > Search for "Spotless Applier" > Install Plugin

Manually:

Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

How it works

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:

Acknowledgments

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.

Contributing

See CONTRIBUTING.md

Release Notes

See CHANGELOG.md

License

See License