File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
main/java/org/codehaus/plexus/compiler
test/java/org/codehaus/plexus/compiler Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 2525 */
2626import java .io .File ;
2727import java .io .IOException ;
28+ import java .util .Collections ;
2829import java .util .HashSet ;
2930import java .util .List ;
3031import java .util .Set ;
@@ -145,10 +146,14 @@ public static String getPathString(List<String> pathElements) {
145146 }
146147
147148 protected static Set <String > getSourceFilesForSourceRoot (CompilerConfiguration config , String sourceLocation ) {
148- DirectoryScanner scanner = new DirectoryScanner ();
149149
150+ DirectoryScanner scanner = new DirectoryScanner ();
150151 scanner .setBasedir (sourceLocation );
151152
153+ if (!scanner .getBasedir ().exists ()) {
154+ return Collections .emptySet ();
155+ }
156+
152157 Set <String > includes = config .getIncludes ();
153158
154159 if (includes != null && !includes .isEmpty ()) {
Original file line number Diff line number Diff line change 1+ package org .codehaus .plexus .compiler ;
2+
3+ import java .io .File ;
4+ import java .util .Set ;
5+
6+ import org .junit .jupiter .api .Test ;
7+
8+ import static org .junit .jupiter .api .Assertions .assertFalse ;
9+ import static org .junit .jupiter .api .Assertions .assertTrue ;
10+
11+ class AbstractCompilerTest {
12+
13+ @ Test
14+ void getSourceFilesForSourceRootShouldReturnEmptyForNotExistingLocation () {
15+
16+ CompilerConfiguration config = new CompilerConfiguration ();
17+ File fileLocation = new File ("non/existing/location" ).getAbsoluteFile ();
18+
19+ assertFalse (fileLocation .exists ());
20+
21+ Set <String > sourcesFile = AbstractCompiler .getSourceFilesForSourceRoot (config , fileLocation .getAbsolutePath ());
22+
23+ assertTrue (sourcesFile .isEmpty ());
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments