Class ProjectSorter


  • public class ProjectSorter
    extends java.lang.Object
    Sort projects by dependencies.
    Version:
    $Id: ProjectSorter.java 793745 2009-07-13 23:24:10Z jdcasey $
    • Constructor Summary

      Constructors 
      Constructor Description
      ProjectSorter​(java.util.List projects)
      Sort a list of projects.
      ProjectSorter​(java.util.List projects, java.util.List selectedProjectNames, java.lang.String resumeFrom, boolean make, boolean makeDependents)  
    • Field Detail

      • dag

        private final org.codehaus.plexus.util.dag.DAG dag
      • projectMap

        private final java.util.Map projectMap
      • sortedProjects

        private final java.util.List<MavenProject> sortedProjects
    • Constructor Detail

      • ProjectSorter

        public ProjectSorter​(java.util.List projects)
                      throws org.codehaus.plexus.util.dag.CycleDetectedException,
                             DuplicateProjectException,
                             MissingProjectException
        Sort a list of projects.
        • collect all the vertices for the projects that we want to build.
        • iterate through the deps of each project and if that dep is within the set of projects we want to build then add an edge, otherwise throw the edge away because that dependency is not within the set of projects we are trying to build. we assume a closed set.
        • do a topo sort on the graph that remains.
        Throws:
        DuplicateProjectException - if any projects are duplicated by id
        MissingProjectException
        org.codehaus.plexus.util.dag.CycleDetectedException
    • Method Detail

      • applyMakeFilter

        private static java.util.List applyMakeFilter​(java.util.List sortedProjects,
                                                      org.codehaus.plexus.util.dag.DAG dag,
                                                      java.util.Map projectMap,
                                                      MavenProject topLevelProject,
                                                      java.util.List selectedProjectNames,
                                                      boolean make,
                                                      boolean makeDependents)
                                               throws MissingProjectException
        Throws:
        MissingProjectException
      • gatherDescendents

        private static void gatherDescendents​(org.codehaus.plexus.util.dag.Vertex v,
                                              java.util.Map projectMap,
                                              java.util.Set out,
                                              java.util.Set visited)
      • gatherAncestors

        private static void gatherAncestors​(org.codehaus.plexus.util.dag.Vertex v,
                                            java.util.Map projectMap,
                                            java.util.Set out,
                                            java.util.Set visited)
      • addEdgeWithParentCheck

        private void addEdgeWithParentCheck​(java.util.Map projectMap,
                                            java.lang.String projectRefId,
                                            MavenProject project,
                                            java.lang.String id)
                                     throws org.codehaus.plexus.util.dag.CycleDetectedException
        Throws:
        org.codehaus.plexus.util.dag.CycleDetectedException
      • getTopLevelProject

        public MavenProject getTopLevelProject()
      • getSortedProjects

        public java.util.List<MavenProject> getSortedProjects()
      • hasMultipleProjects

        public boolean hasMultipleProjects()
      • getDependents

        public java.util.List getDependents​(java.lang.String id)
      • getDAG

        public org.codehaus.plexus.util.dag.DAG getDAG()
      • getProjectMap

        public java.util.Map getProjectMap()