Skip to content

Commit

Permalink
Use the same file traversal here that we generally use elsewhere.
Browse files Browse the repository at this point in the history
This doesn't impose an arbitrary limit on how deeply nested sources can be.
  • Loading branch information
sambsnyd committed Oct 25, 2024
1 parent 0d057b3 commit afe65a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.44.0-SNAPSHOT</version>
<version>5.43.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>rewrite-maven-plugin</name>
Expand Down Expand Up @@ -62,8 +62,8 @@

<properties>
<!-- Pinned versions, as RELEASE would make it into the published pom.xml -->
<rewrite.version>8.39.0-SNAPSHOT</rewrite.version>
<rewrite.kotlin.version>1.22.0-SNAPSHOT</rewrite.kotlin.version>
<rewrite.version>8.38.0</rewrite.version>
<rewrite.kotlin.version>1.21.2</rewrite.kotlin.version>

<!-- using 'ssh' url scheme by default, which assumes a human is performing git operations leveraging an ssh key -->
<developerConnectionUrl>scm:git:ssh://[email protected]/openrewrite/rewrite-maven-plugin.git
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
Expand Down Expand Up @@ -763,9 +761,18 @@ private static List<Path> listSources(Path sourceDirectory, String extension) th
if (!Files.exists(sourceDirectory)) {
return emptyList();
}

try (Stream<Path> files = Files.find(sourceDirectory, 16, (f, a) -> !a.isDirectory() && f.toString().endsWith(extension))) {
return files.collect(toList());
try {
List<Path> result = new ArrayList<>();
Files.walkFileTree(sourceDirectory, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (file.toString().endsWith(extension)) {
result.add(file);
}
return FileVisitResult.CONTINUE;
}
});
return result;
} catch (IOException e) {
throw new MojoExecutionException("Unable to list source files of " + extension, e);
}
Expand Down

0 comments on commit afe65a8

Please sign in to comment.