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
  • Loading branch information
1tchy committed Jan 4, 2022
1 parent d2cc464 commit 2fe5609
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions core/src/main/java/org/moditect/commands/GenerateModuleInfo.java
Expand Up @@ -84,7 +84,7 @@ public class GenerateModuleInfo {
private ToolProvider jdeps;

public GenerateModuleInfo(
Path inputJar, String moduleName, boolean open,
Path inputJar, String moduleName, boolean open,
Set<DependencyDescriptor> dependencies, List<PackageNamePattern> exportPatterns,
List<PackageNamePattern> opensPatterns, List<DependencePattern> requiresPatterns,
Path workingDirectory, Path outputDirectory,
Expand Down Expand Up @@ -249,7 +249,7 @@ private void updateModuleInfo(Map<String, Boolean> optionalityPerModule, ModuleD
if ( moduleName != null ) {
moduleDeclaration.setName( moduleName );
}

opensResources.stream().forEach(resourcePackage -> moduleDeclaration.getDirectives().add(
new ModuleOpensDirective(parseName(resourcePackage), new NodeList<>())
));
Expand Down 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 2fe5609

Please sign in to comment.