Skip to content

Commit

Permalink
Fix SpotlessPlugin.taskMustRunAfterClean
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Dec 5, 2021
1 parent adbfd68 commit 5ee9046
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void configureCleanTask(Project project, Consumer<Delete> onClean) {

/** clean removes the SpotlessCache, so we have to run after clean. */
static void taskMustRunAfterClean(Project project, TaskProvider<?> task) {
configureCleanTask(project, clean -> task.configure(spotless -> spotless.mustRunAfter(clean)));
configureCleanTask(project, clean -> task.get().mustRunAfter(clean));
}

static String capitalize(String input) {
Expand Down

6 comments on commit 5ee9046

@nhoughto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to force eager task configuration for spotlessJava and friends when clean is configured, also due to another Gradle bug around clean it means that the spotless tasks are always configured because clean is always configured.. Was there a problem with the behaviour at spotless version 6.0.2? That seems like the sweet spot for my setup but maybe i'm living with a bug.

gradle/gradle#19498

@nedtwigg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks! This PR is part of #1014, which was about removing the dependency on BasePlugin. But I think this particular commit was not a necessary change. I will revert it shortly.

@nedtwigg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that reverting this commit actually does trigger a bug, but only if the base plugin has not been applied, which is usually a problem only for Android projects.

We fixed this in #1068 which will ship in the next release. If you apply base before calling any Spotless stuff, then you'll get the old 6.0.2 behavior again. If base hasn't been applied yet, then the change in this commit is necessary.

@nedtwigg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Released in 6.1.1, lemme know if it fixes your issue.

@nhoughto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep its fixed, thanks! amazing turnaround. There is one remaining difference between 6.0.2 and 6.1.1 in terms of eager task configuration, testable via gw help --debug | grep Realize on any project, 6.0.2 realised/creates only the help task but 6.1.1 also eagerly creates a spotlessInternalRegisterDependencies task (just one tho), this is likely a separate issue/cause but worth mentioning 👍

2022-01-07T08:55:35.523+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :spotlessInternalRegisterDependencies' started
2022-01-07T08:55:35.601+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Realize task :spotlessInternalRegisterDependencies'
2022-01-07T08:55:35.601+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :spotlessInternalRegisterDependencies' completed
2022-01-07T08:55:43.167+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :help' started
2022-01-07T08:55:43.170+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Realize task :help'
2022-01-07T08:55:43.170+1100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :help' completed

@nedtwigg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger, thanks for the feedback. 👍

Please sign in to comment.