build-coordinator/src/main/java/org/jboss/pnc/coordinator/builder/BuildTasksInitializer.java
private boolean collectDependentConfigurations(BuildConfiguration buildConfiguration,
            BuildConfigurationAudited buildConfigurationAudited,
            Set<BuildConfigurationAudited> toBuild,
            Set<BuildConfiguration> visited,
            boolean checkImplicitDependencies,
            boolean forceRebuild,
            boolean temporaryBuild) {
        if (visited.contains(buildConfiguration)) {
            return toBuild.contains(buildConfigurationAudited);
        }
        visited.add(buildConfiguration);

        boolean requiresRebuild = forceRebuild || datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild);
        for (BuildConfiguration dependency : buildConfiguration.getDependencies()) {
            boolean dependencyRequiresRebuild = collectDependentConfigurations(dependency,
                    datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(dependency.getId()),
                    toBuild,
                    visited,
                    checkImplicitDependencies,
                    forceRebuild,
                    temporaryBuild);

            requiresRebuild = requiresRebuild || dependencyRequiresRebuild;

        }
        log.debug("Configuration {} requires rebuild: ", buildConfiguration.getId(), requiresRebuild);
        if (requiresRebuild) {
            toBuild.add(buildConfigurationAudited);
        }

        return requiresRebuild;
    }
private boolean collectDependentConfigurations(BuildConfiguration buildConfiguration,
            BuildConfigurationAudited buildConfigurationAudited,
            Set<BuildConfigurationAudited> toBuild,
            Set<BuildConfiguration> visited,
            boolean checkImplicitDependencies,
            boolean forceRebuild,
            boolean temporaryBuild) {
        if (visited.contains(buildConfiguration)) {
            return toBuild.contains(buildConfigurationAudited);
        }
        visited.add(buildConfiguration);

        boolean requiresRebuild = forceRebuild || datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild);
        for (BuildConfiguration dependency : buildConfiguration.getDependencies()) {
            boolean dependencyRequiresRebuild = collectDependentConfigurations(dependency,
                    datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(dependency.getId()),
                    toBuild,
                    visited,
                    checkImplicitDependencies,
                    forceRebuild,
                    temporaryBuild);

            requiresRebuild = requiresRebuild || dependencyRequiresRebuild;

        }
        log.debug("Configuration {} requires rebuild: ", buildConfiguration.getId(), requiresRebuild);
        if (requiresRebuild) {
            toBuild.add(buildConfigurationAudited);
        }

        return requiresRebuild;
    }
private boolean collectDependentConfigurations ( BuildConfiguration buildConfiguration , BuildConfigurationAudited buildConfigurationAudited , Set < BuildConfigurationAudited > toBuild , Set < BuildConfiguration > visited , boolean checkImplicitDependencies , boolean forceRebuild , boolean temporaryBuild ) { if ( visited . contains ( buildConfiguration ) ) { return toBuild . contains ( buildConfigurationAudited ) ; } visited . add ( buildConfiguration ) ; boolean requiresRebuild = forceRebuild || datastoreAdapter . requiresRebuild ( buildConfigurationAudited , checkImplicitDependencies , temporaryBuild ) ; for ( BuildConfiguration dependency : buildConfiguration . getDependencies ( ) ) { boolean dependencyRequiresRebuild = collectDependentConfigurations ( dependency , datastoreAdapter . getLatestBuildConfigurationAuditedInitializeBCDependencies ( dependency . getId ( ) ) , toBuild , visited , checkImplicitDependencies , forceRebuild , temporaryBuild ) ; requiresRebuild = requiresRebuild || dependencyRequiresRebuild ; } log . debug ( "Configuration {} requires rebuild: " , buildConfiguration . getId ( ) , requiresRebuild ) ; if ( requiresRebuild ) { toBuild . add ( buildConfigurationAudited ) ; } return requiresRebuild ; }
Collects all BuildConfigurationAudited entities, that needs to be built.

@param buildConfiguration Current BuildConfiguration used to resolve dependencies.
@param buildConfigurationAudited Specific revision of a BuildConfiguration (passed as first parameter) to be potentially built
@param toBuild Set of BuildConfigurationAudited entities planned to be built
@param visited Set of BuildConfigurations, which were already evaluated, if should be built
@param checkImplicitDependencies
@return Returns true, if the buildConfiguration should be rebuilt, otherwise returns false.
Collects all BuildConfigurationAudited entities that needs to be built .