feat(spotless/gradle-plugin): Allow `SpotlessApply` to notify when/what work was done
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- build-system
Research direction
Start with the SpotlessApply Gradle task and its didWork behavior, then review how files copied during execution are tracked. Done means the task exposes or reports which files were changed only when work occurred, with the behavior verified by relevant tests.
Written by the indexing model from the issue text.
Description
Hello Spotless team! We're very thankful for your work on this tool. Seeking review on a proposed feature that we are happy to help incorporate into the project if it sounds like a desirable enhancement.
TL;DR:
We'd like to expose information on which files were auto-fixed by SpotlessApply to propagate that information to our developer experience
Problem Statement
Our current team's workflow is as such for running Spotless:
- On CI, our invocation of
gradle buildrunsspotlessCheck, as is configured by default. All failures are reported by CI and require manual updates - In local use cases,
gradle buildwill instead runspotlessApplyto automatically fix issues. This is biased toward improving the UX during local development
In this case, the developer experience is enhanced by the automatic fixing, however it is less clear when spotlessApply is run on the user's behalf.
It would be preferable to do something more targeted. In this case, we'd prefer to have SpotlessApply (or a finalizer task) only print information in the event that Spotless performed work.
[!NOTE]
In an ideal world, we'd also be able to show the violations that were fixed during the auto-fix phase, such that we could demonstrate to developers "there were X and Y issues, and we've auto-fixed them". This may be out of scope of this more immediate enhancement, but may be interesting to provide.
(Potential) Design
Enhance the SpotlessApply task to output a simple report containing a manifest of all files it copied in on the most recent execution. This output location can be exposed by the task for the specific gradle build, read, and used to provide a more detailed listing of the edited files.
Note: Theoretical Workaround
We've attempted what we thought would be a suitable workaround for the time being:
// build.gradle.kts (or in convention plugin)
tasks.withType<SpotlessApply>() {
doLast {
if(didWork) {
logger.lifecycle("code auto-formatted by spotlessApply")
}
}
}
Unfortunately, even for cases where there are no changes to any of the source files, the SpotlessApply task is still labeled as didWork == true. If we should file this separately as a "bug", please let us know!
- Dominant language
- Java
- Stars
- 5.7k
- Forks
- 560
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diffplug/spotless
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
All issues in diffplug/spotless
Similar issues
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Openbug ecr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Needs: Triage Type: Feature request
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/copilot-sdk#2760 ·