Support gradle for boot version validation
Also add check to see if the file exists in the project.
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
package org.springframework.ide.vscode.commons.java;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -171,4 +174,16 @@ public class SpringProjectUtil {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static File getFile(IJavaProject project, String fileName) throws Exception {
|
||||
Path projectPath = new File(project.getLocationUri()).toPath();
|
||||
if (Files.isDirectory(projectPath, new LinkOption[] {LinkOption.NOFOLLOW_LINKS})) {
|
||||
List<Path>results = Files.walk(projectPath).filter(Files::isRegularFile)
|
||||
.filter(file -> file.toFile().getName().equals(fileName)).collect(Collectors.toList());
|
||||
if (results != null && !results.isEmpty()) {
|
||||
return results.get(0).toFile();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user