Skip to content

Commit 833e4d9

Browse files
committed
Merge branch 'main' into topic/scalafmt-file-path
2 parents bbe2c80 + 4c06539 commit 833e4d9

File tree

23 files changed

+186
-414
lines changed

23 files changed

+186
-414
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1919
* Bump default `shfmt` version to latest `3.7.0` -> `3.8.0`. ([#2050](https://github.com/diffplug/spotless/pull/2050))
2020
* Bump default `ktlint` version to latest `1.1.1` -> `1.2.1`. ([#2057](https://github.com/diffplug/spotless/pull/2057))
2121
* Bump default `sortpom` version to latest `3.4.0` -> `3.4.1`. ([#2078](https://github.com/diffplug/spotless/pull/2078))
22+
* Bump default `sortpom` version to latest `3.4.1` -> `4.0.0` and support versions back to `3.2.1`. ([#2115](https://github.com/diffplug/spotless/pull/2115))
2223
### Removed
2324
* **BREAKING** Remove `JarState.getMavenCoordinate(String prefix)`. ([#1945](https://github.com/diffplug/spotless/pull/1945))
2425
* **BREAKING** Replace `PipeStepPair` with `FenceStep`. ([#1954](https://github.com/diffplug/spotless/pull/1954))
2526
### Fixed
2627
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
2728
* Correctly provide EditorConfig property types for Ktlint ([#2052](https://github.com/diffplug/spotless/issues/2052))
29+
* Made ShadowCopy (`npmInstallCache`) more robust by re-creating the cache dir if it goes missing ([#1984](https://github.com/diffplug/spotless/issues/1984),[2096](https://github.com/diffplug/spotless/pull/2096))
2830

2931
## [2.45.0] - 2024-01-23
3032
### Added

lib-extra/src/main/java/com/diffplug/spotless/extra/EquoBasedStepBuilder.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ public abstract class EquoBasedStepBuilder {
5353
private Iterable<File> settingsFiles = new ArrayList<>();
5454
private Map<String, String> p2Mirrors = Map.of();
5555

56-
/** @deprecated if you use this constructor you *must* call {@link #setVersion(String)} before calling {@link #build()} */
57-
@Deprecated
58-
public EquoBasedStepBuilder(String formatterName, Provisioner mavenProvisioner, SerializedFunction<State, FormatterFunc> stateToFormatter) {
59-
this(formatterName, mavenProvisioner, null, stateToFormatter);
60-
}
61-
6256
/** Initialize valid default configuration, taking latest version */
6357
public EquoBasedStepBuilder(String formatterName, Provisioner mavenProvisioner, @Nullable String defaultVersion, SerializedFunction<State, FormatterFunc> stateToFormatter) {
6458
this.formatterName = formatterName;

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ dependencies {
128128
// scalafmt
129129
scalafmtCompileOnly "org.scalameta:scalafmt-core_2.13:3.7.3"
130130
// sortPom
131-
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.4.1'
131+
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:4.0.0'
132132
sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.12'
133133
// zjsonPatch
134134
zjsonPatchCompileOnly 'com.flipkart.zjsonpatch:zjsonpatch:0.4.14'

lib/src/main/java/com/diffplug/spotless/FormatterFunc.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 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.
@@ -71,12 +71,6 @@ public String apply(String unix) throws Exception {
7171
};
7272
}
7373

74-
/** @deprecated synonym for {@link #ofDangerous(AutoCloseable, FormatterFunc)} */
75-
@Deprecated
76-
public static Closeable of(AutoCloseable closeable, FormatterFunc function) {
77-
return ofDangerous(closeable, function);
78-
}
79-
8074
@FunctionalInterface
8175
interface ResourceFunc<T extends AutoCloseable> {
8276
String apply(T resource, String unix) throws Exception;

lib/src/main/java/com/diffplug/spotless/FormatterStep.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,6 @@ public interface FormatterStep extends Serializable, AutoCloseable {
4646
@Nullable
4747
String format(String rawUnix, File file) throws Exception;
4848

49-
/**
50-
* Returns a new FormatterStep which will only apply its changes
51-
* to files which pass the given filter.
52-
*
53-
* @param contentPattern
54-
* java regular expression used to filter out files which content doesn't contain pattern
55-
* @return FormatterStep
56-
*/
57-
@Deprecated
58-
default FormatterStep filterByContentPattern(String contentPattern) {
59-
return filterByContent(OnMatch.INCLUDE, contentPattern);
60-
}
61-
6249
/**
6350
* Returns a new {@code FormatterStep} which, observing the value of {@code formatIfMatches},
6451
* will only apply, or not, its changes to files which pass the given filter.

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

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

lib/src/main/java/com/diffplug/spotless/npm/NodeModulesCachingNpmProcessFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-2024 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.
@@ -38,11 +38,11 @@ public class NodeModulesCachingNpmProcessFactory implements NpmProcessFactory {
3838

3939
private NodeModulesCachingNpmProcessFactory(@Nonnull File cacheDir) {
4040
this.cacheDir = Objects.requireNonNull(cacheDir);
41-
assertDir(cacheDir);
42-
this.shadowCopy = new ShadowCopy(cacheDir);
41+
assertDir(); // throws if cacheDir is not a directory
42+
this.shadowCopy = new ShadowCopy(this::assertDir);
4343
}
4444

45-
private void assertDir(File cacheDir) {
45+
private synchronized File assertDir() {
4646
if (cacheDir.exists() && !cacheDir.isDirectory()) {
4747
throw new IllegalArgumentException("Cache dir must be a directory");
4848
}
@@ -51,6 +51,7 @@ private void assertDir(File cacheDir) {
5151
throw new IllegalArgumentException("Cache dir could not be created.");
5252
}
5353
}
54+
return cacheDir;
5455
}
5556

5657
public static NodeModulesCachingNpmProcessFactory create(@Nonnull File cacheDir) {

lib/src/main/java/com/diffplug/spotless/npm/ShadowCopy.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-2024 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.
@@ -27,6 +27,7 @@
2727
import java.nio.file.attribute.BasicFileAttributes;
2828
import java.time.Duration;
2929
import java.util.concurrent.TimeoutException;
30+
import java.util.function.Supplier;
3031

3132
import javax.annotation.Nonnull;
3233

@@ -39,13 +40,18 @@ class ShadowCopy {
3940

4041
private static final Logger logger = LoggerFactory.getLogger(ShadowCopy.class);
4142

42-
private final File shadowCopyRoot;
43+
private final Supplier<File> shadowCopyRootSupplier;
4344

44-
public ShadowCopy(@Nonnull File shadowCopyRoot) {
45-
this.shadowCopyRoot = shadowCopyRoot;
45+
public ShadowCopy(@Nonnull Supplier<File> shadowCopyRootSupplier) {
46+
this.shadowCopyRootSupplier = shadowCopyRootSupplier;
47+
}
48+
49+
private File shadowCopyRoot() {
50+
File shadowCopyRoot = shadowCopyRootSupplier.get();
4651
if (!shadowCopyRoot.isDirectory()) {
47-
throw new IllegalArgumentException("Shadow copy root must be a directory: " + shadowCopyRoot);
52+
throw new IllegalStateException("Shadow copy root must be a directory: " + shadowCopyRoot);
4853
}
54+
return shadowCopyRoot;
4955
}
5056

5157
public void addEntry(String key, File orig) {
@@ -86,17 +92,17 @@ private void cleanupReservation(String key) {
8692
}
8793

8894
private Path markerFilePath(String key) {
89-
return Paths.get(shadowCopyRoot.getAbsolutePath(), key + ".marker");
95+
return Paths.get(shadowCopyRoot().getAbsolutePath(), key + ".marker");
9096
}
9197

9298
private File entry(String key, String origName) {
93-
return Paths.get(shadowCopyRoot.getAbsolutePath(), key, origName).toFile();
99+
return Paths.get(shadowCopyRoot().getAbsolutePath(), key, origName).toFile();
94100
}
95101

96102
private boolean reserveSubFolder(String key) {
97103
// put a marker file named "key".marker in "shadowCopyRoot" to make sure no other process is using it or return false if it already exists
98104
try {
99-
Files.createFile(Paths.get(shadowCopyRoot.getAbsolutePath(), key + ".marker"));
105+
Files.createFile(Paths.get(shadowCopyRoot().getAbsolutePath(), key + ".marker"));
100106
return true;
101107
} catch (FileAlreadyExistsException e) {
102108
return false;

lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class SortPomCfg implements Serializable {
2222
private static final long serialVersionUID = 1L;
2323

24-
public String version = "3.4.1";
24+
public String version = "4.0.0";
2525

2626
public String encoding = "UTF-8";
2727

@@ -41,6 +41,8 @@ public class SortPomCfg implements Serializable {
4141

4242
public boolean indentSchemaLocation = false;
4343

44+
public String indentAttribute = null;
45+
4446
public String predefinedSortOrder = "recommended_2008_06";
4547

4648
public String sortOrderFile = null;

0 commit comments

Comments
 (0)