File tree 2 files changed +31
-1
lines changed
main/java/org/codehaus/plexus/compiler
test/java/org/codehaus/plexus/compiler
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 25
25
*/
26
26
import java .io .File ;
27
27
import java .io .IOException ;
28
+ import java .util .Collections ;
28
29
import java .util .HashSet ;
29
30
import java .util .List ;
30
31
import java .util .Set ;
@@ -145,10 +146,14 @@ public static String getPathString(List<String> pathElements) {
145
146
}
146
147
147
148
protected static Set <String > getSourceFilesForSourceRoot (CompilerConfiguration config , String sourceLocation ) {
148
- DirectoryScanner scanner = new DirectoryScanner ();
149
149
150
+ DirectoryScanner scanner = new DirectoryScanner ();
150
151
scanner .setBasedir (sourceLocation );
151
152
153
+ if (!scanner .getBasedir ().exists ()) {
154
+ return Collections .emptySet ();
155
+ }
156
+
152
157
Set <String > includes = config .getIncludes ();
153
158
154
159
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