|
38 | 38 | import java.io.FileNotFoundException; |
39 | 39 | import java.io.IOException; |
40 | 40 | import java.io.OutputStream; |
| 41 | +import java.io.UncheckedIOException; |
| 42 | +import java.nio.file.FileVisitResult; |
41 | 43 | import java.nio.file.Files; |
42 | 44 | import java.nio.file.Path; |
| 45 | +import java.nio.file.SimpleFileVisitor; |
| 46 | +import java.nio.file.attribute.BasicFileAttributes; |
43 | 47 | import java.util.ArrayList; |
44 | 48 | import java.util.Arrays; |
45 | 49 | import java.util.List; |
| 50 | +import java.util.Objects; |
46 | 51 | import java.util.Optional; |
47 | 52 |
|
48 | 53 | import javax.inject.Inject; |
@@ -102,6 +107,23 @@ private File calculateTargetFile(Project target, String buildNumber) { |
102 | 107 | } |
103 | 108 |
|
104 | 109 | private List<File> resolveProjectLogs(File projectDir) { |
| 110 | + // HACK: Some tests leave behind symlinks, and gradle throws an exception if it encounters symlinks. |
| 111 | + // Here we remove them before collecting logs to upload. We could instead build our own path matcher |
| 112 | + // but that seemed more complex than just deleting the irrelevant files. |
| 113 | + try { |
| 114 | + Files.walkFileTree(projectDir.toPath(), new SimpleFileVisitor<>() { |
| 115 | + @Override |
| 116 | + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
| 117 | + if (Files.isSymbolicLink(file)) { |
| 118 | + Files.delete(file); |
| 119 | + } |
| 120 | + return FileVisitResult.CONTINUE; |
| 121 | + } |
| 122 | + }); |
| 123 | + } catch (IOException e) { |
| 124 | + throw new UncheckedIOException(e); |
| 125 | + } |
| 126 | + |
105 | 127 | var projectDirFiles = getFileOperations().fileTree(projectDir); |
106 | 128 | projectDirFiles.include("**/*.hprof"); |
107 | 129 | projectDirFiles.include("**/build/reports/configuration-cache/**"); |
|
0 commit comments