Skip to content

Commit

Permalink
20 fix build with non existant source folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknow0 committed Nov 13, 2023
1 parent 04eecf0 commit 7ab0af1
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -115,11 +116,12 @@ protected void init() throws MojoFailureException {

List<String> compileSourceRoots = project.getCompileSourceRoots();

TypeSolver[] solver = new TypeSolver[compileSourceRoots.size() + 1];
int i = 0;
solver[i++] = new ClassLoaderTypeSolver(classLoader);
for (String s : compileSourceRoots)
solver[i++] = new JavaParserTypeSolver(s);
List<TypeSolver> solver = new ArrayList<>(compileSourceRoots.size() + 1);
solver.add(new ClassLoaderTypeSolver(classLoader));
for (String s : compileSourceRoots) {
if (Files.isDirectory(Paths.get(s)))
solver.add(new JavaParserTypeSolver(s));
}
resolver = new CombinedTypeSolver(solver);
javaSymbolSolver = new JavaSymbolSolver(resolver);
parser = new JavaParser(new ParserConfiguration().setStoreTokens(true).setSymbolResolver(javaSymbolSolver));
Expand Down Expand Up @@ -243,13 +245,13 @@ public SrcWalker(TypeConsumer c) {
}

public void walk(String s) throws MojoFailureException, MojoExecutionException {
Path path = Paths.get(s);
if (!Files.isDirectory(path))
return;

local = Paths.get(s, part);
count = local.getNameCount();
ex = null;

Path path = Paths.get(s);
if (!Files.exists(path))
return;
try {
Files.walkFileTree(path, this);
} catch (IOException e) {
Expand Down

0 comments on commit 7ab0af1

Please sign in to comment.