Prevent IOException in CheckAutoConfigurationClasses
This commit ensures that before walking a source root, the Gradle plugin checks that it exists. This situation can only happen when a Gradle plugin adds new roots to SourceSets, but there are no sources in them. Fixes gh-47142
This commit is contained in:
parent
450eb48303
commit
4d0cce7791
|
|
@ -136,15 +136,17 @@ public abstract class CheckAutoConfigurationClasses extends AutoConfigurationImp
|
|||
private List<File> classFiles() {
|
||||
List<File> classFiles = new ArrayList<>();
|
||||
for (File root : this.classpath.getFiles()) {
|
||||
try (Stream<Path> files = Files.walk(root.toPath())) {
|
||||
files.forEach((file) -> {
|
||||
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
|
||||
classFiles.add(file.toFile());
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
if (root.exists()) {
|
||||
try (Stream<Path> files = Files.walk(root.toPath())) {
|
||||
files.forEach((file) -> {
|
||||
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
|
||||
classFiles.add(file.toFile());
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classFiles;
|
||||
|
|
|
|||
Loading…
Reference in New Issue