Support gradle for boot version validation

Also add check to see if the file exists in the project.
This commit is contained in:
Nieraj Singh
2022-11-11 13:31:50 -08:00
parent 4864c95a86
commit e4ce54e97d
2 changed files with 27 additions and 10 deletions

View File

@@ -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;
}
}