-
Notifications
You must be signed in to change notification settings - Fork 493
Use Task Providers for task initialization #2719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change improves performance by leveraging Gradle's lazy task configuration, avoiding the immediate creation and configuration of the source `SpotlessTask`. The corresponding test suites have been updated to reflect this shift from direct task creation to task registration with providers.
| public class SpotlessPlugin implements Plugin<Project> { | ||
| static final String SPOTLESS_MODERN = "spotlessModern"; | ||
| static final String VER_GRADLE_MIN = "7.3"; | ||
| static final String VER_GRADLE_MIN = "8.1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried every gradle version between 7.3 and 8.1 and it's the only one that can make all tests pass. Otherwise it fails https://github.com/diffplug/spotless/actions/runs/19336302893/job/55313408204
|
Excellent PR, thanks very much! Bumping our minimum to I'll give 24 hours if anyone wants to speak up about the change then I'll merge this, merge the other PRs in the queue, and release. |
| @UntrackedTask(because = "undeclared inputs/outputs") | ||
| public class SpotlessDiagnoseTask extends DefaultTask { | ||
| SpotlessTask source; | ||
| TaskProvider<? extends SpotlessTask> source; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tasks should not depend on other tasks like this. You should properly model your inputs and outputs between tasks.
For things that are shared between tasks, you should use a build service, for everything else you will need serialize to a file and other task should use that file as an input.
Existing set up is fragile and forces you to use UntrackedTask meaning these tasks will run all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree, but SpotlessDiagnoseTask is only used to debug errors in the other tasks. It would never be part of a CI pipeline. Rather than address this tech debt, I think better to just remove the feature
This change improves performance by leveraging Gradle's lazy task configuration, avoiding the immediate creation and configuration of the source
SpotlessTask. The corresponding test suites have been updated to reflect this shift from direct task creation to task registration with providers.