fix: correct spotlessApply path in composite-build violation message - #3007
Open
arimu1 wants to merge 1 commit into
Open
fix: correct spotlessApply path in composite-build violation message#3007arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
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
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).