Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plexus-compilers/plexus-compiler-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult( true, messageList );
}

allSources = resortSourcesToPutModuleInfoFirst( allSources );

// Compile
try
{
Expand Down Expand Up @@ -476,6 +478,29 @@ public void worked( int i, int i1 )
}
}

static List<String> resortSourcesToPutModuleInfoFirst( List<String> allSources )
{
ArrayList<String> resorted = new ArrayList<>();

for ( String mi : allSources )
{
if ( mi.endsWith( "module-info.java" ) )
{
resorted.add( mi );
}
}

for ( String nmi : allSources )
{
if ( !nmi.endsWith( "module-info.java") )
{
resorted.add( nmi );
}
}

return resorted;
}

static boolean processCustomArguments( CompilerConfiguration config, List<String> args )
{
boolean result = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.codehaus.plexus.compiler.eclipse;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.List;
import java.util.stream.Stream;

import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;

class EclipseJavaCompilerTest
{
@ParameterizedTest
@MethodSource( "sources" )
void testReorderedSources( List<String> expected, List<String> inputSources )
{
List<String> resorted = EclipseJavaCompiler.resortSourcesToPutModuleInfoFirst( inputSources );

assertEquals( expected, resorted );
}

static Stream<Arguments> sources()
{
List<String> expectedOrder = asList(
"module-info.java",
"plexus/A.java",
"plexus/B.java",
"eclipse/A.java"
);

List<String> moduleInfoAlreadyFirst = asList(
"module-info.java",
"plexus/A.java",
"plexus/B.java",
"eclipse/A.java"
);

List<String> moduleInfoSomewhereInTheMiddle = asList(
"plexus/A.java",
"module-info.java",
"plexus/B.java",
"eclipse/A.java"
);

List<String> moduleInfoAsLast = asList(
"plexus/A.java",
"plexus/B.java",
"eclipse/A.java",
"module-info.java"
);

return Stream.of(
Arguments.arguments( expectedOrder, moduleInfoAlreadyFirst ),
Arguments.arguments( expectedOrder, moduleInfoSomewhereInTheMiddle ),
Arguments.arguments( expectedOrder, moduleInfoAsLast )
);
}
}