Skip to content

Proposal: Native Support or Integration for Pre-Commit Hook Workflow (Maven & Gradle) #2475

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

Open
mrlonis opened this issue May 5, 2025 · 1 comment

Comments

@mrlonis
Copy link

mrlonis commented May 5, 2025

Hi there! First off, I just want to say how much I appreciate Spotless. It has become a critical part of my workflow, and I really value the consistency and flexibility it brings to code formatting.

One area where I’ve felt a bit of friction, though, is around formal support for pre-commit workflows. To address this, I built separate solutions for both Maven and Gradle that wire up Spotless to Git pre-commit hooks via shell script files that then call Spotless via Maven or Gradle. They work well and are quite robust, but admittedly require a fair amount of setup and documentation, which can be a barrier, especially for teams or developers trying to onboard quickly.

After stepping back from these projects, I wondered whether this kind of functionality might be a candidate for inclusion directly in Spotless itself, or possibly as an officially supported companion module. You may have considered something like this before, and if so, I’d love to hear your thoughts or learn from any past discussions.

I’m opening this issue to start the conversation and gauge whether there's interest in exploring this further. I’d be happy to share what I’ve built and work toward something that fits well with the existing design and philosophy of Spotless.

Thanks for your time, and again, I appreciate the work you all do on this project!

@nedtwigg
Copy link
Member

nedtwigg commented May 5, 2025

formal support for pre-commit workflows

This has been a common request, and we've never supported it well out-of-the-box. Part of this has been about staged files - when the staged content matches the unstaged content, it's easy to do something. But what if the staged content does not match the unstaged?

We have a long-open PR to allow Spotless to apply itself to the staged content, ignoring the disk

Probably the best place to start is documentation. A draft PR which updates the root README.md for the Gradle and Maven plugins with getting-started instructions for your scripts. If those docs would meet the community's requirements, then we can close out these issues and pull your stuff upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants