11
11
import java .io .IOException ;
12
12
import java .net .MalformedURLException ;
13
13
import java .net .URL ;
14
+ import java .nio .file .FileVisitOption ;
14
15
import java .nio .file .Files ;
15
16
import java .nio .file .Path ;
16
17
import java .util .ArrayList ;
24
25
*/
25
26
public class SandboxData {
26
27
28
+ private static final FileVisitOption [] FOLLOW_LINKS = {FileVisitOption .FOLLOW_LINKS };
29
+ private static final FileVisitOption [] NO_VISIT_OPTIONS = {};
30
+
27
31
public static final String [] GROOVY_SUFFIXES = {
28
32
".groovy" , ".gvy" , ".gy" , ".gsh"
29
33
};
@@ -131,7 +135,7 @@ public static String getRelativePath(String path) {
131
135
return FileUtil .relativize (getScriptPath (), path );
132
136
}
133
137
134
- static Collection <File > getSortedFilesOf (File root , Collection <String > paths ) {
138
+ static Collection <File > getSortedFilesOf (File root , Collection <String > paths , boolean debug ) {
135
139
Object2IntLinkedOpenHashMap <File > files = new Object2IntLinkedOpenHashMap <>();
136
140
String separator = File .separatorChar == '\\' ? "\\ \\ " : File .separator ;
137
141
@@ -143,7 +147,7 @@ static Collection<File> getSortedFilesOf(File root, Collection<String> paths) {
143
147
// if we are looking at a specific file, we don't want that to be overridden.
144
148
// otherwise, we want to use the specificity based on the number of file separators.
145
149
int pathSize = StringUtils .countMatches (path , separator );
146
- try (Stream <Path > stream = Files .walk (rootFile .toPath ())) {
150
+ try (Stream <Path > stream = Files .walk (rootFile .toPath (), debug ? FOLLOW_LINKS : NO_VISIT_OPTIONS )) {
147
151
stream .filter (path1 -> isGroovyFile (path1 .toString ()))
148
152
.map (Path ::toFile )
149
153
//.filter(Preprocessor::validatePreprocessors)
0 commit comments