diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index b2c84be366..e07eadad4c 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,11 +3,12 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] -### Changes -* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855)) - ### Added * 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)) +### Fixed +* Fix crash when build dir is a softlink to another directory. ([#1859](https://github.com/diffplug/spotless/pull/1859)) +### Changes +* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855)) ## [2.40.0] - 2023-09-28 ### Added diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java index 8330319cfb..c719419923 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java @@ -26,6 +26,7 @@ import java.io.PrintWriter; import java.io.UncheckedIOException; import java.nio.file.Files; +import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Instant; @@ -144,7 +145,14 @@ private void ensureParentDirExists() { throw new IllegalStateException("Index file does not have a parent dir: " + indexFile); } try { - Files.createDirectories(parentDir); + if (Files.exists(parentDir, LinkOption.NOFOLLOW_LINKS)) { + Path realPath = parentDir.toRealPath(); + if (!Files.exists(realPath)) { + Files.createDirectories(realPath); + } + } else { + Files.createDirectories(parentDir); + } } catch (IOException e) { throw new UncheckedIOException("Unable to create parent directory for the index file: " + indexFile, e); }