Skip to content

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.

License

Notifications You must be signed in to change notification settings

lipiridi/spotless-applier

Repository files navigation

Spotless Applier

Build Version Downloads

⚠️ 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.

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

  • 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.

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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages