mirror of https://github.com/apache/maven.git
[MNG-7271] - Code Improvement
This commit is contained in:
parent
c8d5ba3705
commit
25cf1576cc
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.execution.ProjectDependencyGraph;
|
import org.apache.maven.execution.ProjectDependencyGraph;
|
||||||
import org.apache.maven.project.DuplicateProjectException;
|
import org.apache.maven.project.DuplicateProjectException;
|
||||||
|
@ -166,15 +167,10 @@ public class DefaultProjectDependencyGraph
|
||||||
|
|
||||||
private List<MavenProject> getSortedProjects( Set<String> projectIds )
|
private List<MavenProject> getSortedProjects( Set<String> projectIds )
|
||||||
{
|
{
|
||||||
List<MavenProject> result = new ArrayList<>( projectIds.size() );
|
return projectIds.stream()
|
||||||
for ( String projectId : projectIds )
|
.map( id -> projects.get( id ) )
|
||||||
{
|
.sorted( Comparator.comparingInt( order::get ) )
|
||||||
result.add( projects.get( projectId ) );
|
.collect( Collectors.toList() );
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort( result, new MavenProjectComparator() );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -183,12 +179,4 @@ public class DefaultProjectDependencyGraph
|
||||||
return sorter.getSortedProjects().toString();
|
return sorter.getSortedProjects().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MavenProjectComparator implements Comparator<MavenProject>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare( MavenProject o1, MavenProject o2 )
|
|
||||||
{
|
|
||||||
return order.get( o1 ) - order.get( o2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue