Repository navigation
Add a spotless:report goal for the Maven site - #3175
Open
patpatpat123 wants to merge 3 commits into
Open
patpatpat123 wants to merge 3 commits into
patpatpat123 wants to merge 3 commits into
Conversation
spotless-maven-plugin had no report goal, so maven-site-plugin skipped it and a project's site could not show Spotless results. The new spotless:report goal implements MavenMultiPageReport: mvn site gets a Spotless page with a summary per format, the files that need formatting, each with a colored diff of what spotless:apply would change, and the lint problems. mvn spotless:report writes the same pages on its own. It works with maven-site-plugin 3.12.x (Doxia 1) and 3.20+ (Doxia 2), reuses the plugin-level <build> configuration, and never touches the up-to-date index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! 👋
The problem
A lot of Maven projects publish a site with
mvn site, and most code quality tools show up there under Project Reports: Checkstyle, PMD, SpotBugs, JaCoCo, Surefire. Spotless doesn't, and adding it to<reporting>doesn't help:maven-site-pluginonly renders goals that implementMavenReport, so it skips all three Spotless goals (Skipping non-MavenReportin the debug log). Today the only way to see what Spotless would change is to runspotless:checkand read the console, where the diff is capped at about 50 lines.What this adds
A new
spotless:reportgoal. List the plugin under<reporting>, andmvn sitegets a Spotless page:spotless:applywould change. Tabs and trailing whitespace are highlighted, since they're invisible otherwise.mvn spotless:reportwrites the same pages totarget/sitewithout building the whole site. The report never changes a file and never fails the build because of violations.How it works
SpotlessReportMojoextendsAbstractSpotlessMojo, so it supports every format and step, and looks at exactly the filesspotless:checkwould (ratchetFrom,spotlessFilesand<lintSuppressions>apply).maven-site-plugin3.12.x (Doxia 1, still Maven 3.9's default) and 3.20+ (Doxia 2) both callMavenMultiPageReport.generate(Sink, SinkFactory, Locale), whose signature is the same in reporting API 3.1.1 and 4.0.0, and the renderer only callsSinkmethods that both Doxia 1.11 and 2.0 have (all 47 checked). New runtime dependencies:maven-reporting-apianddoxia-sink-api, about 20 KB, no Doxia renderer.mvn siteconfigures report goals only from<reporting>and<pluginManagement>, so the goal copies the plugin-level<build>configuration onto itself; anything set in<reporting>wins.AbstractSpotlessMojoplusUpToDateChecker.ignoringIndex();checkandapplybehave exactly as before.Testing
mvn sitewithmaven-site-plugin3.12.1 and 3.21.0, including<reporting>overriding<build>.maven-site-plugin3.12.1 and 3.22.0.I couldn't run the full Gradle build locally, so CI will be the first full run of the integration tests and
spotlessCheck. I'll fix whatever comes up, and put this PR's number in the changelog right after opening it.Thanks for Spotless, and for taking a look!
🤖 Generated with Claude Code