1111import java .io .IOException ;
1212import java .net .MalformedURLException ;
1313import java .net .URL ;
14+ import java .nio .file .FileVisitOption ;
1415import java .nio .file .Files ;
1516import java .nio .file .Path ;
1617import java .util .ArrayList ;
2425 */
2526public class SandboxData {
2627
28+ private static final FileVisitOption [] FOLLOW_LINKS = {FileVisitOption .FOLLOW_LINKS };
29+ private static final FileVisitOption [] NO_VISIT_OPTIONS = {};
30+
2731 public static final String [] GROOVY_SUFFIXES = {
2832 ".groovy" , ".gvy" , ".gy" , ".gsh"
2933 };
@@ -131,7 +135,7 @@ public static String getRelativePath(String path) {
131135 return FileUtil .relativize (getScriptPath (), path );
132136 }
133137
134- static Collection <File > getSortedFilesOf (File root , Collection <String > paths ) {
138+ static Collection <File > getSortedFilesOf (File root , Collection <String > paths , boolean debug ) {
135139 Object2IntLinkedOpenHashMap <File > files = new Object2IntLinkedOpenHashMap <>();
136140 String separator = File .separatorChar == '\\' ? "\\ \\ " : File .separator ;
137141
@@ -143,7 +147,7 @@ static Collection<File> getSortedFilesOf(File root, Collection<String> paths) {
143147 // if we are looking at a specific file, we don't want that to be overridden.
144148 // otherwise, we want to use the specificity based on the number of file separators.
145149 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 )) {
147151 stream .filter (path1 -> isGroovyFile (path1 .toString ()))
148152 .map (Path ::toFile )
149153 //.filter(Preprocessor::validatePreprocessors)
0 commit comments