Skip to content

Commit 78eada4

Browse files
committed
Change logic to generate relative path
1 parent 1a3df00 commit 78eada4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.Serializable;
2020
import java.lang.reflect.Constructor;
2121
import java.lang.reflect.Method;
22+
import java.nio.file.Path;
2223
import java.util.List;
2324
import java.util.Objects;
2425

@@ -177,7 +178,8 @@ public String apply(String input) throws Exception {
177178
public String apply(String input, File file) throws Exception {
178179
if (file.isAbsolute()) {
179180
// Cleanthat expects a relative file as input (relative to the root of the repository)
180-
file = new File(".", file.getPath());
181+
Path absolutePath = file.toPath();
182+
file = absolutePath.subpath(1, absolutePath.getNameCount()).toFile();
181183
}
182184
return (String) formatterMethod.invoke(formatter, input, file);
183185
}

0 commit comments

Comments
 (0)