Package org.codehaus.plexus.util.dag

Examples of org.codehaus.plexus.util.dag.DAG


        log.debug("  " + className);
      }
    }

    // build the graph
    DAG graph = new DAG();
    for (ClassDef def : allClasses.values()) {
      graph.addVertex(def.getName());
      for (String name : def.getDependencies()) {
        // resolve dependencies which have class defs to primary class name
        ClassDef dep = allClasses.get(name);
        if (dep != null) {
          name = dep.getName();
        }
        graph.addEdge(def.getName(), name);
      }
    }

    // display some debug information about the graph
    if (debug) {
      log.debug("Vertices:");
      for (Vertex v : graph.getVerticies()) {
        log.debug("  " + v.getLabel());
        if (!v.getParents().isEmpty()) {
          log.debug("    parents:");
          for (Vertex parent : v.getParents()) {
            log.debug("      " + parent.getLabel());
View Full Code Here


    // in a different lifecycle. Though the compiler-plugin has a valid usecase, although
    // that seems to work fine. We need to take versions and lifecycle into account.
    public ProjectSorter( Collection<MavenProject> projects )
        throws CycleDetectedException, DuplicateProjectException
    {
        dag = new DAG();

        // groupId:artifactId:version -> project
        projectMap = new HashMap<String, MavenProject>( projects.size() * 2 );

        // groupId:artifactId -> (version -> vertex)
View Full Code Here

    // in a different lifecycle. Though the compiler-plugin has a valid usecase, although
    // that seems to work fine. We need to take versions and lifecycle into account.
    public ProjectSorter( List<MavenProject> projects )
        throws CycleDetectedException, DuplicateProjectException
    {
        dag = new DAG();

        // groupId:artifactId:version -> project
        projectMap = new HashMap<String, MavenProject>( projects.size() * 2 );

        // groupId:artifactId -> (version -> vertex)
View Full Code Here

    }
   
    public ProjectSorter( List projects, List selectedProjectNames, String resumeFrom, boolean make, boolean makeDependents )
        throws CycleDetectedException, DuplicateProjectException, MissingProjectException
    {
        dag = new DAG();

        projectMap = new HashMap();

        for ( Iterator i = projects.iterator(); i.hasNext(); )
        {
View Full Code Here

     * <li>do a topo sort on the graph that remains.</li>
     * </ul>
     */
    public static List<Project> getSortedProjects( Collection<Project> projects, Logger logger )
    {
        DAG dag = new DAG();

        Map<String, Project> projectMap = new HashMap<String, Project>();

        for ( Project project : projects )
        {
            String id = getProjectId( project );

            if ( dag.getVertex( id ) != null )
            {
                logger.warn( "Project '" + id + "' is duplicated in the reactor." );
            }

            dag.addVertex( id );

            projectMap.put( id, project );
        }

        for ( Project project : projects )
        {
            String id = getProjectId( project );
           
            String projectGroupId = "[" + project.getProjectGroup().getId() + "]";

            // Dependencies
            for ( Object o : project.getDependencies() )
            {
                ProjectDependency dependency = (ProjectDependency) o;

                String dependencyId = projectGroupId + ":" + getDependencyId( dependency );

                if ( dag.getVertex( dependencyId ) != null )
                {
                    try
                    {
                        dag.addEdge( id, dependencyId );
                    }
                    catch ( CycleDetectedException e )
                    {
                        logger.warn( "Ignore cycle detected in project dependencies: " + e.getMessage() );
                    }
                }
            }

            // Parent
            ProjectDependency parent = project.getParent();

            if ( parent != null )
            {
                String parentId = projectGroupId + ":" + getDependencyId( parent );

                if ( dag.getVertex( parentId ) != null )
                {
                    // Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict
                    if ( dag.hasEdge( parentId, id ) )
                    {
                        dag.removeEdge( parentId, id );
                    }
                    try
                    {
                        dag.addEdge( id, parentId );
                    }
                    catch ( CycleDetectedException e )
                    {
                        logger.warn( "Ignore cycle detected in project parent: " + e.getMessage() );
                    }
View Full Code Here

     * </ul>
     */
    public static List<Project> getSortedProjects( Collection<Project> projects, Logger logger )
        throws CycleDetectedException
    {
        DAG dag = new DAG();

        Map<String, Project> projectMap = new HashMap<String, Project>();

        for ( Project project : projects )
        {
            String id = getProjectId( project );

            if ( dag.getVertex( id ) != null )
            {
                logger.warn( "Project '" + id + "' is duplicated in the reactor" );
            }

            dag.addVertex( id );

            projectMap.put( id, project );
        }

        for ( Project project : projects )
        {
            String id = getProjectId( project );

            // Dependencies
            for ( Object o : project.getDependencies() )
            {
                ProjectDependency dependency = (ProjectDependency) o;

                String dependencyId = getDependencyId( dependency );

                if ( dag.getVertex( dependencyId ) != null )
                {
                    dag.addEdge( id, dependencyId );
                }
            }

            // Parent
            ProjectDependency parent = project.getParent();

            if ( parent != null )
            {
                String parentId = getDependencyId( parent );

                if ( dag.getVertex( parentId ) != null )
                {
                    // Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict
                    if ( dag.hasEdge( parentId, id ) )
                    {
                        dag.removeEdge( parentId, id );
                    }
                    dag.addEdge( id, parentId );
                }
            }
        }

        List<Project> sortedProjects = new ArrayList<Project>();
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.dag.DAG

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.