Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the difference to the official plugin? #7

Closed
rlnt opened this issue Oct 25, 2023 · 8 comments
Closed

What's the difference to the official plugin? #7

rlnt opened this issue Oct 25, 2023 · 8 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@rlnt
Copy link

rlnt commented Oct 25, 2023

Just a question. What's the difference between this and the official plugin right here?
https://github.com/ragurney/spotless-intellij-gradle

@lipiridi
Copy link
Owner

Just a question. What's the difference between this and the official plugin right here?
https://github.com/ragurney/spotless-intellij-gradle

Hello!
This plugin supports maven build tool, multi-module projects and gives some additional settings.

@rlnt
Copy link
Author

rlnt commented Oct 26, 2023

One thing I am missing in both plugins is the ability to format on save without third-party tools like Save Actions or File Watchers.

Have you considered adding your plugin as formatter for the Actions on Save section?

That would make it perfect. We are trying to replace the standard IntelliJ formatter we currently use with spotless because you can easily use it inside CI/CD but without automatic formatting in the local IDE, this is not ideal.

There is an open pull request for this on the official plugin but it hasn't been touched in a while:
ragurney/spotless-intellij-gradle#33

@lipiridi
Copy link
Owner

In general, looks like it's real to do. We can call spotless tasks on save.
Furthermore, quick search says we could also add commit check: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009637400-Adding-actions-to-before-commit-toolbar-window

And I think the option above is what you need in order to prevent dev's to push unformatted changes into the repo.
Because of spotless is not a formatter, it's a tool that gives the ability to integrate various formatters. So we'll make calls to an external system, and it's important to understand it's not so fast as native tasks. Especially for maven.

Save action is called many times during developing, and each time the system will little hang while spotless is applying.
Unlike, commit action is called once.

@lipiridi lipiridi added question Further information is requested enhancement New feature or request labels Oct 26, 2023
@rlnt
Copy link
Author

rlnt commented Oct 26, 2023

I would have done that with a pre-commit hook but I am explicitly looking for the save action. I pretty much disabled auto-save and do it manually so this wouldn't be a big issue but I understand the concerns.
Just searching for a better alternative to the default IDEA formatter that is easy to use in the remote repository's actions as well as locally.

@lipiridi
Copy link
Owner

Maybe I don't fully understand your case. Could you explain the CI/CD flow you expect?

@lipiridi
Copy link
Owner

I delved deeper into the precommit check ability and, unfortunately, obtained disappointing results.
Checkin handlers should execute their operations synchronously to maintain the order of checks.
However, this is not possible for external Gradle tasks due to an issue I mentioned a few months ago: https://youtrack.jetbrains.com/issue/IDEA-327879/Executing-Gradle-task-in-ProgressExecutionMode.MODALSYNC-hangs-the-IDE

If we return to the discussion regarding the ability to format code with Spotless on save, a new concern arises:
We can execute the 'apply' task either for a specific file or for the entire project. And what should the plugin do if you have 15 unsaved files? We recognize that dealing with 15 tasks is excessive. Currently, developer handles the situation on its own, depending on the necessity.

The proper way, as I see it, is to natively integrate Spotless into the IDE 🙂

@lipiridi
Copy link
Owner

@rlnt Hello again! The precommit check was implemented in PR #13 due to the fix for the Gradle sync execution bug in the newer IntelliJ IDEA version.

@lipiridi
Copy link
Owner

lipiridi commented Jun 2, 2024

I would have done that with a pre-commit hook but I am explicitly looking for the save action. I pretty much disabled auto-save and do it manually so this wouldn't be a big issue but I understand the concerns. Just searching for a better alternative to the default IDEA formatter that is easy to use in the remote repository's actions as well as locally.

@rlnt Hi again! The action on save was implemented in PR #17, Hope you'll find it useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants