Skip to content

Commit eb54d43

Browse files
authored
Maven build dir can now be a softlink (#1859 fixes #1858)
2 parents 1b0d489 + 70e0015 commit eb54d43

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

plugin-maven/CHANGES.md

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

55
## [Unreleased]
6-
### Changes
7-
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))
8-
96
### Added
107
* CompileSourceRoots and TestCompileSourceRoots are now respected as default includes. These properties are commonly set when adding extra source directories. ([#1846](https://github.com/diffplug/spotless/issues/1846))
8+
### Fixed
9+
* Fix crash when build dir is a softlink to another directory. ([#1859](https://github.com/diffplug/spotless/pull/1859))
10+
### Changes
11+
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))
1112

1213
## [2.40.0] - 2023-09-28
1314
### Added

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.PrintWriter;
2727
import java.io.UncheckedIOException;
2828
import java.nio.file.Files;
29+
import java.nio.file.LinkOption;
2930
import java.nio.file.Path;
3031
import java.nio.file.Paths;
3132
import java.time.Instant;
@@ -144,7 +145,14 @@ private void ensureParentDirExists() {
144145
throw new IllegalStateException("Index file does not have a parent dir: " + indexFile);
145146
}
146147
try {
147-
Files.createDirectories(parentDir);
148+
if (Files.exists(parentDir, LinkOption.NOFOLLOW_LINKS)) {
149+
Path realPath = parentDir.toRealPath();
150+
if (!Files.exists(realPath)) {
151+
Files.createDirectories(realPath);
152+
}
153+
} else {
154+
Files.createDirectories(parentDir);
155+
}
148156
} catch (IOException e) {
149157
throw new UncheckedIOException("Unable to create parent directory for the index file: " + indexFile, e);
150158
}

0 commit comments

Comments
 (0)