Skip to content

Commit 6e45c6f

Browse files
committed
Merge remote-tracking branch 'origin/main' into EnforceVar_jdk11
2 parents 958864d + 6789a1d commit 6e45c6f

File tree

70 files changed

+2239
-255
lines changed

Some content is hidden

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

70 files changed

+2239
-255
lines changed

.github/workflows/ci.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
pull_request:
77
push:
88
branches: [main]
9+
workflow_dispatch:
10+
911
concurrency:
1012
group: ${{ github.workflow }}-${{ github.ref }}
1113
cancel-in-progress: true
@@ -31,9 +33,9 @@ jobs:
3133
with:
3234
gradle-home-cache-cleanup: true
3335
- name: spotlessCheck
34-
run: ./gradlew spotlessCheck --build-cache
36+
run: ./gradlew spotlessCheck
3537
- name: assemble testClasses
36-
run: ./gradlew assemble testClasses --build-cache
38+
run: ./gradlew assemble testClasses
3739
build:
3840
needs: sanityCheck
3941
strategy:
@@ -69,13 +71,13 @@ jobs:
6971
gradle-home-cache-cleanup: true
7072
- name: build (maven-only)
7173
if: matrix.kind == 'maven'
72-
run: ./gradlew :plugin-maven:build -x spotlessCheck --build-cache
74+
run: ./gradlew :plugin-maven:build -x spotlessCheck
7375
- name: build (everything-but-maven)
7476
if: matrix.kind == 'gradle'
75-
run: ./gradlew build -x spotlessCheck --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
77+
run: ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true
7678
- name: test npm
7779
if: matrix.kind == 'npm'
78-
run: ./gradlew testNpm --build-cache
80+
run: ./gradlew testNpm
7981
- name: junit result
8082
uses: mikepenz/action-junit-report@v3
8183
if: always() # always run even if the previous step fails

CHANGES.md

+13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13+
### Changes
14+
* We are now opting in to Gradle's new stable configuration cache. ([#1591](https://github.com/diffplug/spotless/pull/1591))
15+
16+
## [2.36.0] - 2023-02-27
17+
### Added
18+
* `gradlew equoIde` opens a repeatable clean Spotless dev environment. ([#1523](https://github.com/diffplug/spotless/pull/1523))
19+
* `cleanthat` added `includeDraft` option, to include draft mutators from composite mutators. ([#1574](https://github.com/diffplug/spotless/pull/1574))
20+
* `npm`-based formatters now support caching of `node_modules` directory ([#1590](https://github.com/diffplug/spotless/pull/1590))
21+
### Fixed
22+
* `JacksonJsonFormatterFunc` handles json files with an Array as root. ([#1585](https://github.com/diffplug/spotless/pull/1585))
23+
### Changes
24+
* Bump default `cleanthat` version to latest `2.1` -> `2.6` ([#1569](https://github.com/diffplug/spotless/pull/1569) and [#1574](https://github.com/diffplug/spotless/pull/1574))
25+
* Reduce logging-noise created by `npm`-based formatters ([#1590](https://github.com/diffplug/spotless/pull/1590) fixes [#1582](https://github.com/diffplug/spotless/issues/1582))
1326

1427
## [2.35.0] - 2023-02-10
1528
### Added

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to Spotless
22

3-
Pull requests are welcome, preferably against `main`. Feel free to develop spotless any way you like.
3+
Pull requests are welcome, preferably against `main`. Feel free to develop spotless any way you like, but if you like Eclipse and Gradle Buildship then [`gradlew equoIde` will install an IDE and set it up for you](https://github.com/equodev/equo-ide).
44

55
## How Spotless works
66

_ext/gradle/p2-fat-jar-setup.gradle

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ext {
1212
p2Dependencies = "p2Dependencies not defined in project"
1313
}
1414

15-
// Some JARs may include JARs themselfs, which shall be unpacked and added to the embedded class folder.
15+
// Some JARs may include JARs themselfs, which shall be unpacked and added to the embedded class folder.
1616
if (!project.hasProperty('internalJars')) {
1717
internalJars = []
1818
}
@@ -35,13 +35,13 @@ ext {
3535
'META-INF/*.SF', // ... so all signatures are filtered
3636
]
3737
}
38-
38+
3939
// Map fat-JAR resources path if JAR file name does not correspond to plugin package name (e.g. required for internal plugins)
4040
if (!project.hasProperty('fatJarResourcesMap')) {
4141
fatJarResourcesMap = [:]
4242
}
43-
44-
43+
44+
4545
// The directory contains all external classes for the fat-jar
4646
embeddedClassesDirName = 'build/embeddedClasses'
4747
embeddedClassesDir = project.file(embeddedClassesDirName)
@@ -163,3 +163,7 @@ apply plugin: 'idea'
163163
// Encure that the dependent classes are preovided for compilation if project is build via Eclipse instead of command line
164164
tasks.idea.dependsOn(unjarEmbeddedClasses)
165165

166+
tasks.named('ideaModule') {
167+
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13480")
168+
}
169+

build.gradle

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
plugins {
2+
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
3+
id 'dev.equo.ide' version '0.16.0'
4+
}
5+
equoIde {
6+
branding().title('Spotless').icon(file('_images/spotless_logo.png'))
7+
welcome().openUrl('https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md')
8+
gradleBuildship()
9+
}
10+
11+
repositories {
12+
mavenCentral()
13+
}
14+
115
apply from: rootProject.file('gradle/java-publish.gradle')
216
apply from: rootProject.file('gradle/changelog.gradle')
317
allprojects {

gradle.properties

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# To fix metaspace errors
2-
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=1024m -Dfile.encoding=UTF-8
2+
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1024m -Dfile.encoding=UTF-8
3+
org.gradle.parallel=true
4+
org.gradle.caching=true
5+
org.gradle.unsafe.configuration-cache=true
6+
37
name=spotless
48
description=Spotless - keep your code spotless with Gradle
59
org=diffplug

gradle/java-publish.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ if (System.env['JITPACK'] == 'true' || version.endsWith('-SNAPSHOT')) {
200200
}
201201
}
202202

203+
tasks.withType(Sign).configureEach {
204+
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13470")
205+
}
206+
203207
tasks.withType(AbstractArchiveTask).configureEach {
204208
preserveFileTimestamps = false
205209
reproducibleFileOrder = true

gradle/java-setup.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
3030
reports {
3131
html.enabled = true
3232
}
33+
notCompatibleWithConfigurationCache("https://github.com/spotbugs/spotbugs-gradle-plugin/issues/670")
3334
}
3435

3536
tasks.named('spotbugsMain') {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

lib/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ tasks.named("check").configure {
5656

5757
dependencies {
5858
compileOnly 'org.slf4j:slf4j-api:2.0.0'
59+
testCommonImplementation 'org.slf4j:slf4j-api:2.0.0'
60+
5961
// zero runtime reqs is a hard requirements for spotless-lib
6062
// if you need a dep, put it in lib-extra
6163
testCommonImplementation "org.junit.jupiter:junit-jupiter:$VER_JUNIT"
@@ -108,8 +110,8 @@ dependencies {
108110

109111
gsonCompileOnly 'com.google.code.gson:gson:2.10.1'
110112

111-
cleanthatCompileOnly 'io.github.solven-eu.cleanthat:java:2.2'
112-
compatCleanthat2Dot1CompileAndTestOnly 'io.github.solven-eu.cleanthat:java:2.2'
113+
cleanthatCompileOnly 'io.github.solven-eu.cleanthat:java:2.6'
114+
compatCleanthat2Dot1CompileAndTestOnly 'io.github.solven-eu.cleanthat:java:2.6'
113115
}
114116

115117
// we'll hold the core lib to a high standard

lib/src/cleanthat/java/com/diffplug/spotless/glue/java/JavaCleanthatRefactorerFunc.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ public class JavaCleanthatRefactorerFunc implements FormatterFunc {
4242
private String jdkVersion;
4343
private List<String> included;
4444
private List<String> excluded;
45+
private boolean includeDraft;
4546

46-
public JavaCleanthatRefactorerFunc(String jdkVersion, List<String> included, List<String> excluded) {
47+
public JavaCleanthatRefactorerFunc(String jdkVersion, List<String> included, List<String> excluded, boolean includeDraft) {
4748
this.jdkVersion = jdkVersion == null ? IJdkVersionConstants.JDK_8 : jdkVersion;
4849
this.included = included == null ? Collections.emptyList() : included;
4950
this.excluded = excluded == null ? Collections.emptyList() : excluded;
51+
this.includeDraft = includeDraft;
5052
}
5153

5254
public JavaCleanthatRefactorerFunc() {
53-
this(IJdkVersionConstants.JDK_8, Arrays.asList(JavaRefactorerProperties.WILDCARD), Arrays.asList());
55+
this(IJdkVersionConstants.JDK_8, Arrays.asList("SafeAndConsensual"), Arrays.asList(), false);
5456
}
5557

5658
@Override
@@ -79,9 +81,11 @@ private String doApply(String input) throws InterruptedException, IOException {
7981
refactorerProperties.setIncluded(included);
8082
refactorerProperties.setExcluded(excluded);
8183

84+
refactorerProperties.setIncludeDraft(includeDraft);
85+
8286
JavaRefactorer refactorer = new JavaRefactorer(engineProperties, refactorerProperties);
8387

84-
LOGGER.debug("Processing sourceJdk={} included={} excluded={}", jdkVersion, included, excluded);
88+
LOGGER.debug("Processing sourceJdk={} included={} excluded={}", jdkVersion, included, excluded, includeDraft);
8589
LOGGER.debug("Available mutators: {}", JavaRefactorer.getAllIncluded());
8690

8791
// Spotless calls steps always with LF eol.

lib/src/jackson/java/com/diffplug/spotless/glue/json/AJacksonFormatterFunc.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package com.diffplug.spotless.glue.json;
1717

1818
import java.io.IOException;
19-
import java.util.Map;
2019

2120
import com.fasterxml.jackson.core.JsonFactory;
2221
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -49,7 +48,7 @@ public String apply(String input) throws Exception {
4948
protected String format(ObjectMapper objectMapper, String input) throws IllegalArgumentException, IOException {
5049
try {
5150
// ObjectNode is not compatible with SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS
52-
Map objectNode = objectMapper.readValue(input, Map.class);
51+
Object objectNode = objectMapper.readValue(input, inferType(input));
5352
String output = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectNode);
5453

5554
return output;
@@ -58,6 +57,13 @@ protected String format(ObjectMapper objectMapper, String input) throws IllegalA
5857
}
5958
}
6059

60+
/**
61+
*
62+
* @param input
63+
* @return the {@link Class} into which the String has to be deserialized
64+
*/
65+
protected abstract Class<?> inferType(String input);
66+
6167
/**
6268
* @return a {@link JsonFactory}. May be overridden to handle alternative formats.
6369
* @see <a href="https://github.com/FasterXML/jackson-dataformats-text">jackson-dataformats-text</a>

lib/src/jackson/java/com/diffplug/spotless/glue/json/JacksonJsonFormatterFunc.java

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616
package com.diffplug.spotless.glue.json;
1717

18+
import java.util.Collection;
19+
import java.util.Map;
20+
1821
import com.fasterxml.jackson.core.JsonFactory;
1922
import com.fasterxml.jackson.core.JsonFactoryBuilder;
2023
import com.fasterxml.jackson.core.JsonGenerator;
@@ -37,6 +40,15 @@ public JacksonJsonFormatterFunc(JacksonJsonConfig jacksonConfig) {
3740
this.jacksonConfig = jacksonConfig;
3841
}
3942

43+
@Override
44+
protected Class<?> inferType(String input) {
45+
if (input.trim().startsWith("[")) {
46+
return Collection.class;
47+
} else {
48+
return Map.class;
49+
}
50+
}
51+
4052
/**
4153
* @return a {@link JsonFactory}. May be overridden to handle alternative formats.
4254
* @see <a href="https://github.com/FasterXML/jackson-dataformats-text">jackson-dataformats-text</a>

lib/src/jackson/java/com/diffplug/spotless/glue/yaml/JacksonYamlFormatterFunc.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ protected JsonFactory makeJsonFactory() {
5858
return yamlFactoryBuilder.build();
5959
}
6060

61+
@Override
62+
protected Class<?> inferType(String input) {
63+
return JsonNode.class;
64+
}
65+
6166
@Override
6267
protected String format(ObjectMapper objectMapper, String input) throws IllegalArgumentException, IOException {
6368
try {
6469
// https://stackoverflow.com/questions/25222327/deserialize-pojos-from-multiple-yaml-documents-in-a-single-file-in-jackson
6570
// https://github.com/FasterXML/jackson-dataformats-text/issues/66#issuecomment-375328648
6671
JsonParser yamlParser = objectMapper.getFactory().createParser(input);
67-
List<JsonNode> documents = objectMapper.readValues(yamlParser, JsonNode.class).readAll();
72+
List<?> documents = objectMapper.readValues(yamlParser, inferType(input)).readAll();
6873

6974
// https://github.com/FasterXML/jackson-dataformats-text/issues/66#issuecomment-554265055
7075
// https://github.com/FasterXML/jackson-dataformats-text/issues/66#issuecomment-554265055

0 commit comments

Comments
 (0)