Skip to content

Commit b3a6e36

Browse files
authored
No need for clean to trigger configuration of the spotless tasks if 'base' was already applied (#1068)
2 parents 0d95529 + 6f4fafa commit b3a6e36

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

plugin-gradle/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* If the `base` plugin has already been applied, then there is no need for configuration of the `clean` task to trigger configuration of the Spotless tasks ([#1068](https://github.com/diffplug/spotless/pull/1068)).
68
### Changed
79
* Bumped default DiKTat from `0.4.0` to `1.0.1`. This is a breaking change for DiKTat users on the default version, because some rules were renamed/changed. Check [DiKTat changelog](https://github.com/analysis-dev/diktat/releases) for details.
810

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessPlugin.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,7 +63,13 @@ static void configureCleanTask(Project project, Consumer<Delete> onClean) {
6363

6464
/** clean removes the SpotlessCache, so we have to run after clean. */
6565
static void taskMustRunAfterClean(Project project, TaskProvider<?> task) {
66-
configureCleanTask(project, clean -> task.get().mustRunAfter(clean));
66+
if (project.getPlugins().hasPlugin(BasePlugin.class)) {
67+
// if we know that the clean task is around, then we can configure lazily
68+
task.configure(t -> t.mustRunAfter(BasePlugin.CLEAN_TASK_NAME));
69+
} else {
70+
// otherwise, we trigger configuration when the clean task gets configured
71+
configureCleanTask(project, clean -> task.get().mustRunAfter(clean));
72+
}
6773
}
6874

6975
static String capitalize(String input) {

0 commit comments

Comments
 (0)