private List<MavenProject> calculateProjectsToBuild( Set<String> changedFilePaths )
    {
        Set<MavenProject> changedProjects = new HashSet<MavenProject>( projects.size() );
        for ( String path: changedFilePaths )
        {
            MavenProject p = findProjectFor( path );
            changedProjects.add( p );
        }

        Set<MavenProject> changedAndDependentProjects = new HashSet<MavenProject>( projects.size() );
        for ( MavenProject p: changedProjects )
        {
            changedAndDependentProjects.add( p );
            List<MavenProject> deps = session.getProjectDependencyGraph().getDownstreamProjects( p, true/*transitive*/ );
            for ( MavenProject depP: deps )
            {
                if ( projects.contains( depP ) )
                {
                    changedAndDependentProjects.addAll( deps );
                }
            }
        }

        List<MavenProject> result = new ArrayList<MavenProject>( changedAndDependentProjects.size() );
        for ( MavenProject p: projects )
        {
            if ( changedAndDependentProjects.contains( p ) )
            {
                result.add( p );
            }
        }
        return result;
    }
private List<MavenProject> calculateProjectsToBuild( Set<String> changedFilePaths )
    {
        Set<MavenProject> changedProjects = new HashSet<MavenProject>( projects.size() );
        for ( String path: changedFilePaths )
        {
            MavenProject p = findProjectFor( path );
            changedProjects.add( p );
        }

        Set<MavenProject> changedAndDependentProjects = new HashSet<MavenProject>( projects.size() );
        for ( MavenProject p: changedProjects )
        {
            changedAndDependentProjects.add( p );
            List<MavenProject> deps = session.getProjectDependencyGraph().getDownstreamProjects( p, true );
            for ( MavenProject depP: deps )
            {
                if ( projects.contains( depP ) )
                {
                    changedAndDependentProjects.addAll( deps );
                }
            }
        }

        List<MavenProject> result = new ArrayList<MavenProject>( changedAndDependentProjects.size() );
        for ( MavenProject p: projects )
        {
            if ( changedAndDependentProjects.contains( p ) )
            {
                result.add( p );
            }
        }
        return result;
    }
private List < MavenProject > calculateProjectsToBuild ( Set < String > changedFilePaths ) { Set < MavenProject > changedProjects = new HashSet < MavenProject > ( projects . size ( ) ) ; for ( String path : changedFilePaths ) { MavenProject p = findProjectFor ( path ) ; changedProjects . add ( p ) ; } Set < MavenProject > changedAndDependentProjects = new HashSet < MavenProject > ( projects . size ( ) ) ; for ( MavenProject p : changedProjects ) { changedAndDependentProjects . add ( p ) ; List < MavenProject > deps = session . getProjectDependencyGraph ( ) . getDownstreamProjects ( p , true /*transitive*/ ) ; for ( MavenProject depP : deps ) { if ( projects . contains ( depP ) ) { changedAndDependentProjects . addAll ( deps ) ; } } } List < MavenProject > result = new ArrayList < MavenProject > ( changedAndDependentProjects . size ( ) ) ; for ( MavenProject p : projects ) { if ( changedAndDependentProjects . contains ( p ) ) { result . add ( p ) ; } } return result ; }
=== TEST ===================================================================================
=== TEST ===================================================================================