Skip to content

Commit

Permalink
Fixed problem with duplicate modules while generating module-info (mo…
Browse files Browse the repository at this point in the history
…ditect#113) (#1)

Co-authored-by: Itchy <itchy@laurinmurer.ch>
  • Loading branch information
aseovic and 1tchy committed Apr 15, 2022
1 parent c4849a9 commit 90b553d
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions core/src/main/java/org/moditect/commands/GenerateModuleInfo.java
Expand Up @@ -344,28 +344,20 @@ private Map<String, Boolean> generateModuleInfo() throws AssertionError {
command.add( workingDirectory.toString() );

if ( !dependencies.isEmpty() ) {
StringBuilder modules = new StringBuilder();
StringBuilder modulePath = new StringBuilder();
boolean isFirst = true;
List<String> modules = new ArrayList<>();
List<String> modulePath = new ArrayList<>();

for ( DependencyDescriptor dependency : dependencies ) {
if ( isFirst ) {
isFirst = false;
}
else {
modules.append( "," );
modulePath.append( File.pathSeparator );
}
String moduleName = DependencyDescriptor.getAutoModuleNameFromInputJar(dependency.getPath(), dependency.getAssignedModuleName());
modules.append( moduleName );
modules.add( moduleName );
optionalityPerModule.put( moduleName, dependency.isOptional() );
modulePath.append( dependency.getPath() );
modulePath.add( dependency.getPath().toString() );
}

command.add( "--add-modules" );
command.add( modules.toString() );
command.add( modules.stream().distinct().collect( Collectors.joining( "," ) ) );
command.add( "--module-path" );
command.add( modulePath.toString() );
command.add( modulePath.stream().distinct().collect( Collectors.joining( File.pathSeparator ) ) );
}

command.addAll( jdepsExtraArgs );
Expand Down

0 comments on commit 90b553d

Please sign in to comment.