Skip to content

Commit da8a898

Browse files
authored
Merge branch 'main' into announce-intellij-plugin
2 parents f1a5ff6 + 4860830 commit da8a898

27 files changed

+410
-96
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ indent_size = 2
1616
# Doc: https://youtrack.jetbrains.com/issue/IDEA-170643#focus=streamItem-27-3708697.0-0
1717
ij_java_imports_layout = java.**,|,javax.**,|,org.**,|,com.**,|,com.diffplug.**,|,*
1818
ij_java_use_single_class_imports = true
19+
20+
[*.xml.mustache]
21+
indent_style = space

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ 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+
14+
## [2.21.2] - 2022-01-07
15+
### Fixed
16+
* Update IndentStep to allow leading space on multiline comments ([#1072](https://github.com/diffplug/spotless/pull/1072)).
17+
18+
## [2.21.1] - 2022-01-06
1319
### Changed
1420
* 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.
1521

PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Please **DO NOT FORCE PUSH**. Don't worry about messy history, it's easier to do code review if we can tell what happened after the review, and force pushing breaks that.
2+
13
Please make sure that your [PR allows edits from maintainers](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/). Sometimes its faster for us to just fix something than it is to describe how to fix it.
24

35
![Allow edits from maintainers](https://help.github.com/assets/images/help/pull_requests/allow-maintainers-to-make-edits-sidebar-checkbox.png)

lib/src/main/java/com/diffplug/spotless/generic/IndentStep.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 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.
@@ -100,6 +100,9 @@ String format(String raw) {
100100
++contentStart;
101101
}
102102

103+
// detect potential multi-line comments
104+
boolean mightBeMultiLineComment = (contentStart < raw.length()) && (raw.charAt(contentStart) == '*');
105+
103106
// add the leading space in a canonical way
104107
if (numSpaces > 0) {
105108
switch (state.type) {
@@ -112,6 +115,9 @@ String format(String raw) {
112115
for (int i = 0; i < numSpaces / state.numSpacesPerTab; ++i) {
113116
builder.append('\t');
114117
}
118+
if (mightBeMultiLineComment && (numSpaces % state.numSpacesPerTab == 1)) {
119+
builder.append(' ');
120+
}
115121
break;
116122
default:
117123
throw new IllegalArgumentException("Unexpected enum " + state.type);

plugin-gradle/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
66
### Added
77
* 🎉🎉🎉 [**IntelliJ plugin**](https://plugins.jetbrains.com/plugin/18321-spotless-gradle) thanks to [@ragurney](https://github.com/ragurney) 🎉🎉🎉
88

9+
## [6.1.2] - 2022-01-07
10+
### Fixed
11+
* Update IndentStep to allow leading space on multiline comments ([#1072](https://github.com/diffplug/spotless/pull/1072)).
12+
13+
## [6.1.1] - 2022-01-06
914
### Fixed
1015
* 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)).
1116
### Changed

plugin-gradle/README.md

Lines changed: 27 additions & 27 deletions
Large diffs are not rendered by default.

plugin-maven/CHANGES.md

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

55
## [Unreleased]
6+
7+
## [2.19.2] - 2022-01-10
8+
### Fixed
9+
* Enabling the upToDateChecking with the plugin configured inside pluginManagement, with an additional dependency and running under Maven 3.6.3 leads to a java.io.NotSerializableException. ([#1074](https://github.com/diffplug/spotless/pull/1074)).
10+
11+
## [2.19.1] - 2022-01-07
12+
### Fixed
13+
* Update IndentStep to allow leading space on multiline comments ([#1072](https://github.com/diffplug/spotless/pull/1072)).
14+
15+
## [2.19.0] - 2022-01-06
16+
### Added
17+
* Support custom index files for incremental up-to-date checking ([#1055](https://github.com/diffplug/spotless/pull/1055)).
618
### Fixed
719
* Remove Java files from default Maven Groovy formatting ([#1051](https://github.com/diffplug/spotless/pull/1051)).
820
* Before this release, the default target of groovy was

plugin-maven/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ output = [
1212
].join('\n');
1313
-->
1414
[![Maven central](https://img.shields.io/badge/mavencentral-com.diffplug.spotless%3Aspotless--maven--plugin-blue.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.diffplug.spotless%22%20AND%20a%3A%22spotless-maven-plugin%22)
15-
[![Javadoc](https://img.shields.io/badge/javadoc-yes-blue.svg)](https://javadoc.io/doc/com.diffplug.spotless/spotless-maven-plugin/2.18.0/index.html)
16-
[![Changelog](https://img.shields.io/badge/changelog-2.18.0-brightgreen.svg)](CHANGES.md)
15+
[![Javadoc](https://img.shields.io/badge/javadoc-yes-blue.svg)](https://javadoc.io/doc/com.diffplug.spotless/spotless-maven-plugin/2.19.2/index.html)
16+
[![Changelog](https://img.shields.io/badge/changelog-2.19.2-brightgreen.svg)](CHANGES.md)
1717

1818
[![Circle CI](https://circleci.com/gh/diffplug/spotless/tree/main.svg?style=shield)](https://circleci.com/gh/diffplug/spotless/tree/main)
1919
[![Live chat](https://img.shields.io/badge/gitter-chat-brightgreen.svg)](https://gitter.im/diffplug/spotless)
@@ -181,9 +181,8 @@ any other maven phase (i.e. compile) then it can be configured as below;
181181
<importOrder /> <!-- standard import order -->
182182
<importOrder> <!-- or a custom ordering -->
183183
<wildcardsLast>false</wildcardsLast> <!-- Optional, default false. Sort wildcard import after specific imports -->
184-
<order>java,javax,org,com,com.diffplug,</order> <!-- or use <file>${project.basedir}/eclipse.importorder</file> -->
185-
<!-- You probably want an empty string at the end - all of the
186-
imports you didn't specify explicitly will go there. -->
184+
<order>java,javax,org,com,com.diffplug,,\\#com.diffplug,\\#</order> <!-- or use <file>${project.basedir}/eclipse.importorder</file> -->
185+
<!-- you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports. -->
187186
</importOrder>
188187

189188
<removeUnusedImports /> <!-- self-explanatory -->
@@ -250,10 +249,8 @@ This is a workaround to a [pending issue](https://github.com/diffplug/spotless/i
250249

251250
<importOrder /> <!-- standard import order -->
252251
<importOrder> <!-- or a custom ordering -->
253-
<order>java,javax,org,com,com.diffplug,</order> <!-- or use <file>
254-
/eclipse.importorder</file> -->
255-
<!-- You probably want an empty string at the end - all of the
256-
imports you didn't specify explicitly will go there. -->
252+
<order>java,javax,org,com,com.diffplug,,\\#com.diffplug,\\#</order> <!-- or use <file>${project.basedir}/eclipse.importorder</file> -->
253+
<!-- you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports -->
257254
</importOrder>
258255

259256
<greclipse /> <!-- has its own section below -->
@@ -936,6 +933,7 @@ enable incremental up-to-date checking with the following configuration:
936933
<configuration>
937934
<upToDateChecking>
938935
<enabled>true</enabled>
936+
<indexFile>${project.basedir}/custom-index-file</indexFile> <!-- optional, default is ${project.build.directory}/spotless-index -->
939937
</upToDateChecking>
940938
<!-- ... define formats ... -->
941939
</configuration>
@@ -946,7 +944,7 @@ The index file contains source file paths and corresponding last modified timest
946944
It allows Spotless to skip already formatted files that have not changed.
947945

948946
**Note:** the index file is located in the `target` directory. Executing `mvn clean` will delete
949-
the index file, and Spotless will need to check/format all the source files.
947+
the index file, and Spotless will need to check/format all the source files. You can override the default index file location with the `indexFile` configuration parameter.
950948

951949
Spotless will remove the index file when up-to-date checking is explicitly turned off with the
952950
following configuration:
@@ -955,6 +953,7 @@ following configuration:
955953
<configuration>
956954
<upToDateChecking>
957955
<enabled>false</enabled>
956+
<indexFile>${project.basedir}/custom-index-file</indexFile> <!-- optional, default is ${project.build.directory}/spotless-index -->
958957
</upToDateChecking>
959958
<!-- ... define formats ... -->
960959
</configuration>

plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java

Lines changed: 10 additions & 4 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.
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.nio.file.Path;
2223
import java.util.ArrayList;
2324
import java.util.Arrays;
2425
import java.util.Collections;
@@ -71,7 +72,7 @@
7172
import com.diffplug.spotless.maven.typescript.Typescript;
7273

7374
public abstract class AbstractSpotlessMojo extends AbstractMojo {
74-
75+
private static final String DEFAULT_INDEX_FILE_NAME = "spotless-index";
7576
private static final String DEFAULT_ENCODING = "UTF-8";
7677
private static final String DEFAULT_LINE_ENDINGS = "GIT_ATTRIBUTES";
7778
static final String GOAL_CHECK = "check";
@@ -324,10 +325,15 @@ private List<FormatterStepFactory> getFormatterStepFactories() {
324325
}
325326

326327
private UpToDateChecker createUpToDateChecker(Iterable<Formatter> formatters) {
328+
Path indexFile = upToDateChecking == null ? null : upToDateChecking.getIndexFile();
329+
if (indexFile == null) {
330+
Path targetDir = project.getBasedir().toPath().resolve(project.getBuild().getDirectory());
331+
indexFile = targetDir.resolve(DEFAULT_INDEX_FILE_NAME);
332+
}
327333
if (upToDateChecking != null && upToDateChecking.isEnabled()) {
328334
getLog().info("Up-to-date checking enabled");
329-
return UpToDateChecker.forProject(project, formatters, getLog());
335+
return UpToDateChecker.forProject(project, indexFile, formatters, getLog());
330336
}
331-
return UpToDateChecker.noop(project, getLog());
337+
return UpToDateChecker.noop(project, indexFile, getLog());
332338
}
333339
}

plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndexConfig.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-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.
@@ -20,18 +20,17 @@
2020
import org.apache.maven.project.MavenProject;
2121

2222
class FileIndexConfig {
23-
24-
private static final String INDEX_FILE_NAME = "spotless-index";
25-
2623
private final MavenProject project;
2724
private final PluginFingerprint pluginFingerprint;
25+
private final Path indexFile;
2826

29-
FileIndexConfig(MavenProject project) {
30-
this(project, PluginFingerprint.empty());
27+
FileIndexConfig(MavenProject project, Path indexFile) {
28+
this(project, indexFile, PluginFingerprint.empty());
3129
}
3230

33-
FileIndexConfig(MavenProject project, PluginFingerprint pluginFingerprint) {
31+
FileIndexConfig(MavenProject project, Path indexFile, PluginFingerprint pluginFingerprint) {
3432
this.project = project;
33+
this.indexFile = indexFile;
3534
this.pluginFingerprint = pluginFingerprint;
3635
}
3736

@@ -40,8 +39,7 @@ Path getProjectDir() {
4039
}
4140

4241
Path getIndexFile() {
43-
Path targetDir = getProjectDir().resolve(project.getBuild().getDirectory());
44-
return targetDir.resolve(INDEX_FILE_NAME);
42+
return indexFile;
4543
}
4644

4745
PluginFingerprint getPluginFingerprint() {

0 commit comments

Comments
 (0)