File tree 3 files changed +90
-0
lines changed
plexus-compilers/plexus-compiler-eclipse
main/java/org/codehaus/plexus/compiler/eclipse
test/java/org/codehaus/plexus/compiler/eclipse
3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 36
36
<artifactId >junit-jupiter-api</artifactId >
37
37
<scope >test</scope >
38
38
</dependency >
39
+ <dependency >
40
+ <groupId >org.junit.jupiter</groupId >
41
+ <artifactId >junit-jupiter-params</artifactId >
42
+ <scope >test</scope >
43
+ </dependency >
39
44
<dependency >
40
45
<groupId >org.hamcrest</groupId >
41
46
<artifactId >hamcrest</artifactId >
Original file line number Diff line number Diff line change @@ -262,6 +262,8 @@ public CompilerResult performCompile( CompilerConfiguration config )
262
262
return new CompilerResult ( true , messageList );
263
263
}
264
264
265
+ allSources = resortSourcesToPutModuleInfoFirst ( allSources );
266
+
265
267
// Compile
266
268
try
267
269
{
@@ -476,6 +478,29 @@ public void worked( int i, int i1 )
476
478
}
477
479
}
478
480
481
+ static List <String > resortSourcesToPutModuleInfoFirst ( List <String > allSources )
482
+ {
483
+ ArrayList <String > resorted = new ArrayList <>();
484
+
485
+ for ( String mi : allSources )
486
+ {
487
+ if ( mi .endsWith ( "module-info.java" ) )
488
+ {
489
+ resorted .add ( mi );
490
+ }
491
+ }
492
+
493
+ for ( String nmi : allSources )
494
+ {
495
+ if ( !nmi .endsWith ( "module-info.java" ) )
496
+ {
497
+ resorted .add ( nmi );
498
+ }
499
+ }
500
+
501
+ return resorted ;
502
+ }
503
+
479
504
static boolean processCustomArguments ( CompilerConfiguration config , List <String > args )
480
505
{
481
506
boolean result = false ;
Original file line number Diff line number Diff line change
1
+ package org .codehaus .plexus .compiler .eclipse ;
2
+
3
+ import org .junit .jupiter .params .ParameterizedTest ;
4
+ import org .junit .jupiter .params .provider .Arguments ;
5
+ import org .junit .jupiter .params .provider .MethodSource ;
6
+
7
+ import java .util .List ;
8
+ import java .util .stream .Stream ;
9
+
10
+ import static java .util .Arrays .asList ;
11
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
12
+
13
+ class EclipseJavaCompilerTest
14
+ {
15
+ @ ParameterizedTest
16
+ @ MethodSource ( "sources" )
17
+ void testReorderedSources ( List <String > expected , List <String > inputSources )
18
+ {
19
+ List <String > resorted = EclipseJavaCompiler .resortSourcesToPutModuleInfoFirst ( inputSources );
20
+
21
+ assertEquals ( expected , resorted );
22
+ }
23
+
24
+ static Stream <Arguments > sources ()
25
+ {
26
+ List <String > expectedOrder = asList (
27
+ "module-info.java" ,
28
+ "plexus/A.java" ,
29
+ "plexus/B.java" ,
30
+ "eclipse/A.java"
31
+ );
32
+
33
+ List <String > moduleInfoAlreadyFirst = asList (
34
+ "module-info.java" ,
35
+ "plexus/A.java" ,
36
+ "plexus/B.java" ,
37
+ "eclipse/A.java"
38
+ );
39
+
40
+ List <String > moduleInfoSomewhereInTheMiddle = asList (
41
+ "plexus/A.java" ,
42
+ "module-info.java" ,
43
+ "plexus/B.java" ,
44
+ "eclipse/A.java"
45
+ );
46
+
47
+ List <String > moduleInfoAsLast = asList (
48
+ "plexus/A.java" ,
49
+ "plexus/B.java" ,
50
+ "eclipse/A.java" ,
51
+ "module-info.java"
52
+ );
53
+
54
+ return Stream .of (
55
+ Arguments .arguments ( expectedOrder , moduleInfoAlreadyFirst ),
56
+ Arguments .arguments ( expectedOrder , moduleInfoSomewhereInTheMiddle ),
57
+ Arguments .arguments ( expectedOrder , moduleInfoAsLast )
58
+ );
59
+ }
60
+ }
You can’t perform that action at this time.
0 commit comments