fix: correct spotlessApply path in composite-build violation message - #3007
Merged
nedtwigg merged 3 commits intoAug 15, 2026
Merged
Conversation
In included/composite builds, bare spotlessApply does not select tasks from the included build. Use the build-tree path (e.g. :my-utils:spotlessApply) in the spotlessCheck run-to-fix message. Standalone multi-project builds still suggest bare spotlessApply (diffplug#2592). Fixes diffplug#2421
…otlessApply-path # Conflicts: # plugin-gradle/CHANGES.md
Gradle.getParent() is @nullable, and the loop called it twice — once in the while condition and again into the local. SpotBugs treats the second call as independent of the first, so the local was possibly-null where it was dereferenced. Call it once per iteration into a local the loop condition guards. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
nedtwigg
enabled auto-merge
August 15, 2026 23:15
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.
Problem
Fixes #2421.
When Spotless is applied inside an included build of a Gradle composite,
spotlessChecksuggested a barespotlessApply(historically:spotlessApplyfromproject.pathalone). Task name selectors do not match tasks in included builds, so the suggested command does not fix the violations.For example:
A violation in
my-utilsis fixed by./gradlew :my-utils:spotlessApply, not./gradlew spotlessApplyor./gradlew :spotlessApply.Fix
spotlessApplyso one command still fixes every multi-project violation (#2592).gradle.parent != null), suggest the build-tree task path, e.g.:my-utils:spotlessApplyor:my-utils:lib:spotlessApply.Project.getBuildTreePath()(Gradle 8.10+); fall back to reconstructing the path fromGradle.getIncludedBuilds()on older supported versions.Changes
plugin-gradle/.../SpotlessCheck.java— composite-awarespotlessApplySelectorplugin-gradle/.../CompositeBuildRunToFixMessageTest.java— included root, included subproject, and standalone casesplugin-gradle/CHANGES.md— Unreleased note linking Logged message to fix formatting violations is incorrect when applied to a composite build #2421Testing
10/10 passed (JDK 17).