Skip to content

Commit 2f32f0d

Browse files
authored
com.diffplug.spotless 5.0
2 parents 6d43bcc + 83eb761 commit 2f32f0d

File tree

73 files changed

+756
-1888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+756
-1888
lines changed

.circleci/config.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ jobs:
9292
command: ./gradlew :plugin-maven:check --build-cache
9393
- store_test_results:
9494
path: plugin-maven/build/test-results/test
95-
test_gradle_modern_8:
96-
<< : *env_gradle
97-
steps:
98-
- checkout
99-
- *restore_cache_wrapper
100-
- *restore_cache_deps
101-
- run:
102-
name: gradlew :plugin-gradle:modernTest
103-
command: ./gradlew :plugin-gradle:modernTest --build-cache
104-
- store_test_results:
105-
path: plugin-gradle/build/test-results/modernTest
10695
test_npm_8:
10796
<< : *env_gradle
10897
docker:
@@ -223,9 +212,6 @@ workflows:
223212
- test_npm_8:
224213
requires:
225214
- assemble_testClasses
226-
- test_gradle_modern_8:
227-
requires:
228-
- assemble_testClasses
229215
deploy:
230216
jobs:
231217
- changelog_print:

plugin-gradle/CHANGES-5.x-PREVIEW.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

plugin-gradle/CHANGES.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,37 @@
22

33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

5-
**5.x preview:** If you are using Gradle 5.4+, you can preview thew upcoming `com.diffplug.spotless` plugin by adding `-PspotlessModern`, see [CHANGES-5.x-PREVIEW.md](CHANGES-5.x-PREVIEW.md) for details.
6-
75
## [Unreleased]
86

7+
This release is *exactly* the same as `4.5.1`, except:
8+
9+
- it now has plugin id `com.diffplug.spotless`, rather than `com.diffplug.gradle.spotless` ([why](https://dev.to/nedtwigg/names-in-java-maven-and-gradle-2fm2))
10+
- the minimum required Gradle has bumped from `2.14` to `5.4`
11+
- all deprecated functionality has been removed
12+
- `-PspotlessModern=true` (introduced in [`4.3.0`](#430---2020-06-05)) is now always on
13+
14+
If `id 'com.diffplug.gradle.spotless' version '4.5.1'` works without deprecation warnings, then you can upgrade to `id 'com.diffplug.spotless' version '5.0.0'` and no changes will be required.
15+
16+
* **BREAKING** All deprecated functionality has been removed ([#640](https://github.com/diffplug/spotless/pull/640)).
17+
* (dev-only) `SpotlessTask` was deleted, and `SpotlessTaskModern` was renamed to `SpotlessTask` (ditto for `SpotlessPlugin` and `SpotlessExtension`).
18+
* Introduced in earlier versions, but formerly gated behind `-PspotlessModern=true`
19+
* We now calculate incremental builds using the new `InputChanges` rather than the deprecated `IncrementalTaskInputs`. ([#607](https://github.com/diffplug/spotless/pull/607))
20+
* We now use Gradle's config avoidance APIs. ([#617](https://github.com/diffplug/spotless/pull/617))
21+
* Spotless no longer creates any tasks eagerly. ([#622](https://github.com/diffplug/spotless/pull/622))
22+
* **BREAKING** The closures inside each format specification are now executed lazily on task configuration. ([#618](https://github.com/diffplug/spotless/pull/618))
23+
24+
```groovy
25+
String isEager = 'nope'
26+
spotless {
27+
java {
28+
isEager = 'yup'
29+
}
30+
}
31+
println "isEager $isEager"
32+
// 'com.diffplug.gradle.spotless' -> isEager yup
33+
// 'com.diffplug.spotless' -> isEager nope
34+
```
35+
936
## [4.5.1] - 2020-07-04
1037
### Fixed
1138
* Git-native handling of line endings was broken, now fixed ([#639](https://github.com/diffplug/spotless/pull/639)).

plugin-gradle/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ Spotless supports all of Gradle's built-in performance features (incremental bui
120120

121121
### Requirements
122122

123-
Spotless requires JRE 8+, and Gradle 2.14+. Some steps require JRE 11+, `Unsupported major.minor version` means you're using a step that needs a newer JRE.
123+
Spotless requires JRE 8+, and Gradle 5.4+. Some steps require JRE 11+, `Unsupported major.minor version` means you're using a step that needs a newer JRE.
124+
125+
If you're stuck on an older version of Gradle, `id 'com.diffplug.gradle.spotless' version '4.5.1'` supports all the way back to Gradle 2.x`.
124126

125127
<a name="applying-to-java-source"></a>
126128

plugin-gradle/build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ task npmTest(type: Test) {
4141
}
4242
}
4343

44-
task modernTest(type: Test) {
45-
systemProperty 'spotlessModern', 'true'
46-
useJUnit {
47-
excludeCategories 'com.diffplug.spotless.category.NpmTest', 'com.diffplug.gradle.spotless.ExcludeFromPluginGradleModern'
48-
}
49-
}
50-
5144
// make it easy for eclipse to run against latest build
5245
tasks.eclipse.dependsOn(pluginUnderTestMetadata)
5346

@@ -57,11 +50,17 @@ tasks.eclipse.dependsOn(pluginUnderTestMetadata)
5750
gradlePlugin {
5851
plugins {
5952
spotlessPlugin {
60-
id = 'com.diffplug.gradle.spotless'
53+
id = 'com.diffplug.spotless'
6154
implementationClass = 'com.diffplug.gradle.spotless.SpotlessPlugin'
6255
displayName = 'Spotless formatting plugin'
6356
description = project.description
6457
}
58+
spotlessPluginLegacy {
59+
id = 'com.diffplug.gradle.spotless'
60+
implementationClass = 'com.diffplug.gradle.spotless.SpotlessPluginRedirect'
61+
displayName = 'Spotless formatting plugin (legacy)'
62+
description = project.description
63+
}
6564
}
6665
}
6766
if (version.endsWith('-SNAPSHOT')) {
@@ -87,6 +86,9 @@ if (version.endsWith('-SNAPSHOT')) {
8786
]
8887
plugins {
8988
spotlessPlugin {
89+
id = 'com.diffplug.spotless'
90+
}
91+
spotlessPluginLegacy {
9092
id = 'com.diffplug.gradle.spotless'
9193
}
9294
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class Antlr4Extension extends FormatExtension implements HasBuiltinDelimiterForLicense {
2525
static final String NAME = "antlr4";
2626

27-
public Antlr4Extension(SpotlessExtensionBase rootExtension) {
27+
public Antlr4Extension(SpotlessExtension rootExtension) {
2828
super(rootExtension);
2929
}
3030

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

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull;
1919

20-
import java.util.Arrays;
21-
import java.util.Collections;
22-
import java.util.List;
23-
import java.util.stream.Collectors;
24-
2520
import org.gradle.api.Project;
2621

2722
import com.diffplug.spotless.cpp.CppDefaults;
@@ -31,32 +26,18 @@
3126
public class CppExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
3227
static final String NAME = "cpp";
3328

34-
public CppExtension(SpotlessExtensionBase spotless) {
29+
public CppExtension(SpotlessExtension spotless) {
3530
super(spotless);
3631
}
3732

3833
public EclipseConfig eclipseCdt() {
39-
return new EclipseConfig(EclipseCdtFormatterStep.defaultVersion());
34+
return eclipseCdt(EclipseCdtFormatterStep.defaultVersion());
4035
}
4136

4237
public EclipseConfig eclipseCdt(String version) {
4338
return new EclipseConfig(version);
4439
}
4540

46-
/** Use {@link #eclipseCdt} instead. */
47-
@Deprecated
48-
public EclipseConfig eclipse() {
49-
getProject().getLogger().warn("Spotless: in the `cpp { }` block, use `eclipseCdt()` instead of `eclipse()`");
50-
return new EclipseConfig(EclipseCdtFormatterStep.defaultVersion());
51-
}
52-
53-
/** Use {@link #eclipseCdt} instead. */
54-
@Deprecated
55-
public EclipseConfig eclipse(String version) {
56-
getProject().getLogger().warn("Spotless: in the `cpp { }` block, use `eclipseCdt('" + version + "')` instead of `eclipse('" + version + "')`");
57-
return new EclipseConfig(version);
58-
}
59-
6041
public class EclipseConfig {
6142
private final EclipseBasedStepBuilder builder;
6243

@@ -77,29 +58,11 @@ public void configFile(Object... configFiles) {
7758
@Override
7859
protected void setupTask(SpotlessTask task) {
7960
if (target == null) {
80-
/*
81-
* The org.gradle.language.c and org.gradle.language.cpp source sets are seldom used.
82-
* Most Gradle C/C++ use external CMake builds (so the source location is unknown to Gradle).
83-
* Hence file extension based filtering is used in line with the org.eclipse.core.contenttype.contentTypes<
84-
* defined by the CDT plugin.
85-
*/
86-
noDefaultTarget();
87-
target(FILE_FILTER.toArray());
61+
throw noDefaultTargetException();
8862
}
8963
super.setupTask(task);
9064
}
9165

92-
/**
93-
* Filter based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
94-
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
95-
*/
96-
@Deprecated
97-
private static final List<String> FILE_FILTER = Collections.unmodifiableList(
98-
Arrays.asList("c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc")
99-
.stream().map(s -> {
100-
return "**/*." + s;
101-
}).collect(Collectors.toList()));
102-
10366
@Override
10467
public LicenseHeaderConfig licenseHeader(String licenseHeader) {
10568
return licenseHeader(licenseHeader, CppDefaults.DELIMITER_EXPR);

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

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)