Skip to content

Conversation

@simonlebras
Copy link
Contributor

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.

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";
Copy link
Contributor Author

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

@nedtwigg
Copy link
Member

nedtwigg commented Nov 13, 2025

Excellent PR, thanks very much! Bumping our minimum to 8.1 (Apr 2023) seems worth this improvement. We need to improve the release notes to call this out, but I can do that, this PR is already good enough to merge.

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;

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.

Copy link
Member

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

@nedtwigg nedtwigg merged commit a2ce4e2 into diffplug:main Nov 14, 2025
20 of 21 checks passed
@simonlebras simonlebras deleted the lazy-task branch November 14, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants