Skip to content

Commit f237fd4

Browse files
committed
fix the crash #1858 when the maven build dir is a softlink to an actual directory
1 parent d346ef8 commit f237fd4

File tree

1 file changed

+8
-1
lines changed
  • plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,14 @@ private void ensureParentDirExists() {
144144
throw new IllegalStateException("Index file does not have a parent dir: " + indexFile);
145145
}
146146
try {
147-
Files.createDirectories(parentDir);
147+
if (Files.exists(parentDir, LinkOption.NOFOLLOW_LINKS)) {
148+
Path realPath = parentDir.toRealPath();
149+
if (!Files.exists(realPath)) {
150+
Files.createDirectories(realPath);
151+
}
152+
} else {
153+
Files.createDirectories(parentDir);
154+
}
148155
} catch (IOException e) {
149156
throw new UncheckedIOException("Unable to create parent directory for the index file: " + indexFile, e);
150157
}

0 commit comments

Comments
 (0)