public RunResult run(RunDecision runDecision) throws DetectUserFriendlyException, InterruptedException, IntegrationException {
        //TODO: Better way for run manager to get dependencies so he can be tested. (And better ways of creating his objects)
        final DetectConfiguration detectConfiguration = detectContext.getBean(DetectConfiguration.class);
        final DetectConfigurationFactory detectConfigurationFactory = detectContext.getBean(DetectConfigurationFactory.class);
        final DirectoryManager directoryManager = detectContext.getBean(DirectoryManager.class);
        final EventSystem eventSystem = detectContext.getBean(EventSystem.class);
        final CodeLocationNameManager codeLocationNameManager = detectContext.getBean(CodeLocationNameManager.class);
        final BdioCodeLocationCreator bdioCodeLocationCreator = detectContext.getBean(BdioCodeLocationCreator.class);
        final ConnectionManager connectionManager = detectContext.getBean(ConnectionManager.class);
        final DetectInfo detectInfo = detectContext.getBean(DetectInfo.class);
        final RunResult runResult = new RunResult();
        final RunOptions runOptions = detectConfigurationFactory.createRunOptions();
        final DetectToolFilter detectToolFilter = runOptions.getDetectToolFilter();
        if (runDecision.willRunBlackduck()) {
            logger.info("Black Duck tools will run.");
            final ConnectivityManager connectivityManager = detectContext.getBean(ConnectivityManager.class);
            if (connectivityManager.getPhoneHomeManager().isPresent()) {
                connectivityManager.getPhoneHomeManager().get().startPhoneHome();
            }
            DetectorEnvironment detectorEnvironment = new DetectorEnvironment(directoryManager.getSourceDirectory(), Collections.emptySet(), 0, null, false);
            DetectorFactory detectorFactory = detectContext.getBean(DetectorFactory.class);
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.DOCKER)) {
                logger.info("Will include the docker tool.");
                ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createDockerDetector(detectorEnvironment));
                toolRunner.run(runResult);
                logger.info("Docker actions finished.");
            } else {
                logger.info("Docker tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.BAZEL)) {
                logger.info("Will include the bazel tool.");
                ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createBazelDetector(detectorEnvironment));
                toolRunner.run(runResult);
                logger.info("Bazel actions finished.");
            } else {
                logger.info("Bazel tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.DETECTOR)) {
                logger.info("Will include the detector tool.");
                final String projectBomTool = detectConfiguration.getProperty(DetectProperty.DETECT_PROJECT_DETECTOR, PropertyAuthority.None);
                final SearchOptions searchOptions = detectConfigurationFactory.createSearchOptions(directoryManager.getSourceDirectory());
                final DetectorTool detectorTool = new DetectorTool(detectContext);
                final DetectorToolResult detectorToolResult = detectorTool.performDetectors(searchOptions, projectBomTool);
                runResult.addToolNameVersionIfPresent(DetectTool.DETECTOR, detectorToolResult.bomToolProjectNameVersion);
                runResult.addDetectCodeLocations(detectorToolResult.bomToolCodeLocations);
                runResult.addApplicableDetectors(detectorToolResult.applicableDetectorTypes);
                if (detectorToolResult.failedDetectorTypes.size() > 0) {
                    eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_DETECTOR, "A detector failed."));
                }
                logger.info("Detector actions finished.");
            } else {
                logger.info("Detector tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            logger.info("Completed code location tools.");
            logger.info("Determining project info.");
            final ProjectNameVersionOptions projectNameVersionOptions = detectConfigurationFactory.createProjectNameVersionOptions(directoryManager.getSourceDirectory().getName());
            final ProjectNameVersionDecider projectNameVersionDecider = new ProjectNameVersionDecider(projectNameVersionOptions);
            final NameVersion projectNameVersion = projectNameVersionDecider.decideProjectNameVersion(runOptions.getPreferredTools(), runResult.getDetectToolProjectInfo());
            logger.info("Project name: " + projectNameVersion.getName());
            logger.info("Project version: " + projectNameVersion.getVersion());
            Optional<ProjectVersionWrapper> projectVersionWrapper = Optional.empty();
            if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                logger.info("Getting or creating project.");
                final DetectProjectServiceOptions options = detectConfigurationFactory.createDetectProjectServiceOptions();
                final DetectProjectMappingService detectProjectMappingService = new DetectProjectMappingService(blackDuckServicesFactory.createBlackDuckService());
                final DetectProjectService detectProjectService = new DetectProjectService(blackDuckServicesFactory, options, detectProjectMappingService);
                projectVersionWrapper = Optional.of(detectProjectService.createOrUpdateHubProject(projectNameVersion, options.getApplicationId()));
                if (projectVersionWrapper.isPresent() && runOptions.shouldUnmapCodeLocations()) {
                    logger.info("Unmapping code locations.");
                    final DetectCodeLocationUnmapService detectCodeLocationUnmapService = new DetectCodeLocationUnmapService(blackDuckServicesFactory.createBlackDuckService(), blackDuckServicesFactory.createCodeLocationService());
                    detectCodeLocationUnmapService.unmapCodeLocations(projectVersionWrapper.get().getProjectVersionView());
                } else {
                    logger.debug("Will not unmap code locations: Project view was not present, or should not unmap code locations.");
                }
            } else {
                logger.debug("Detect is not online, and will not create the project.");
            }
            logger.info("Completed project and version actions.");
            logger.info("Processing Detect Code Locations.");
            final CodeLocationWaitData codeLocationWaitData = new CodeLocationWaitData();
            final BdioManager bdioManager = new BdioManager(detectInfo, new SimpleBdioFactory(), new IntegrationEscapeUtil(), codeLocationNameManager, detectConfiguration, bdioCodeLocationCreator, directoryManager, eventSystem);
            final BdioResult bdioResult = bdioManager.createBdioFiles(runOptions.getAggregateName(), projectNameVersion, runResult.getDetectCodeLocations());
            if (bdioResult.getUploadTargets().size() > 0) {
                logger.info("Created " + bdioResult.getUploadTargets().size() + " BDIO files.");
                bdioResult.getUploadTargets().forEach(it -> eventSystem.publishEvent(Event.OutputFileOfInterest, it.getUploadFile()));
                if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                    logger.info("Uploading BDIO files.");
                    final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                    final DetectBdioUploadService detectBdioUploadService = new DetectBdioUploadService(detectConfiguration, blackDuckServicesFactory.createBdioUploadService(), eventSystem);
                    final CodeLocationCreationData<UploadBatchOutput> uploadBatchOutputCodeLocationCreationData = detectBdioUploadService.uploadBdioFiles(bdioResult.getUploadTargets());
                    codeLocationWaitData.setFromBdioCodeLocationCreationData(uploadBatchOutputCodeLocationCreationData);
                }
            } else {
                logger.debug("Did not create any BDIO files.");
            }
            logger.info("Completed Detect Code Location processing.");
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN)) {
                logger.info("Will include the signature scanner tool.");
                final BlackDuckSignatureScannerOptions blackDuckSignatureScannerOptions = detectConfigurationFactory.createBlackDuckSignatureScannerOptions();
                final BlackDuckSignatureScannerTool blackDuckSignatureScannerTool = new BlackDuckSignatureScannerTool(blackDuckSignatureScannerOptions, detectContext);
                final SignatureScannerToolResult signatureScannerToolResult = blackDuckSignatureScannerTool.runScanTool(projectNameVersion, runResult.getDockerTar());
                if (signatureScannerToolResult.getResult() == Result.SUCCESS && signatureScannerToolResult.getCreationData().isPresent()) {
                    codeLocationWaitData.setFromSignatureScannerCodeLocationCreationData(signatureScannerToolResult.getCreationData().get());
                }
                logger.info("Signature scanner actions finished.");
            } else {
                logger.info("Signature scan tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.BINARY_SCAN)) {
                logger.info("Will include the binary scanner tool.");
                if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                    final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                    final BlackDuckBinaryScannerTool blackDuckBinaryScanner = new BlackDuckBinaryScannerTool(eventSystem, codeLocationNameManager, detectConfiguration, blackDuckServicesFactory);
                    BinaryScanToolResult result = blackDuckBinaryScanner.performBinaryScanActions(projectNameVersion);
                    if (result.isSuccessful()) {
                        codeLocationWaitData.setFromBinaryScan(result.getNotificationTaskRange(), result.getCodeLocationNames());
                    }
                }
                logger.info("Binary scanner actions finished.");
            } else {
                logger.info("Binary scan tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (projectVersionWrapper.isPresent() && connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                logger.info("Will perform Black Duck post actions.");
                final BlackduckReportOptions blackduckReportOptions = detectConfigurationFactory.createReportOptions();
                final PolicyCheckOptions policyCheckOptions = detectConfigurationFactory.createPolicyCheckOptions();
                final long timeoutInSeconds = detectConfigurationFactory.getTimeoutInSeconds();
                final BlackduckPostActions blackduckPostActions = new BlackduckPostActions(blackDuckServicesFactory, eventSystem);
                blackduckPostActions.perform(blackduckReportOptions, policyCheckOptions, codeLocationWaitData, projectVersionWrapper.get(), timeoutInSeconds);
                final boolean hasAtLeastOneBdio = !bdioResult.getUploadTargets().isEmpty();
                final boolean shouldHaveScanned = detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN);
                if (hasAtLeastOneBdio || shouldHaveScanned) {
                    final Optional<String> componentsLink = projectVersionWrapper.get().getProjectVersionView().getFirstLink(ProjectVersionView.COMPONENTS_LINK);
                    if (componentsLink.isPresent()) {
                        logger.info(String.format("To see your results, follow the URL: %s", componentsLink.get()));
                    }
                }
                logger.info("Black Duck actions have finished.");
            } else {
                logger.debug("Will not perform post actions: Detect is not online.");
            }
        } else {
            logger.info("Black Duck tools will NOT be run.");
        }
        if (runDecision.willRunPolaris()) {
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.POLARIS)) {
                logger.info("Will include the Polaris tool.");
                final PolarisTool polarisTool = new PolarisTool(eventSystem, directoryManager, new ExecutableRunner(), connectionManager, detectConfiguration);
                polarisTool.runPolaris(new Slf4jIntLogger(logger), directoryManager.getSourceDirectory());
                logger.info("Polaris actions finished.");
            } else {
                logger.info("Polaris CLI tool will not be run.");
            }
        } else {
            logger.info("Polaris tools will NOT be run.");
        }
        logger.info("All tools have finished.");
        logger.info(ReportConstants.RUN_SEPARATOR);
        return runResult;
    }
public RunResult run(RunDecision runDecision) throws DetectUserFriendlyException, InterruptedException, IntegrationException {
       
        final DetectConfiguration detectConfiguration = detectContext.getBean(DetectConfiguration.class);
        final DetectConfigurationFactory detectConfigurationFactory = detectContext.getBean(DetectConfigurationFactory.class);
        final DirectoryManager directoryManager = detectContext.getBean(DirectoryManager.class);
        final EventSystem eventSystem = detectContext.getBean(EventSystem.class);
        final CodeLocationNameManager codeLocationNameManager = detectContext.getBean(CodeLocationNameManager.class);
        final BdioCodeLocationCreator bdioCodeLocationCreator = detectContext.getBean(BdioCodeLocationCreator.class);
        final ConnectionManager connectionManager = detectContext.getBean(ConnectionManager.class);
        final DetectInfo detectInfo = detectContext.getBean(DetectInfo.class);
        final RunResult runResult = new RunResult();
        final RunOptions runOptions = detectConfigurationFactory.createRunOptions();
        final DetectToolFilter detectToolFilter = runOptions.getDetectToolFilter();
        if (runDecision.willRunBlackduck()) {
            logger.info("Black Duck tools will run.");
            final ConnectivityManager connectivityManager = detectContext.getBean(ConnectivityManager.class);
            if (connectivityManager.getPhoneHomeManager().isPresent()) {
                connectivityManager.getPhoneHomeManager().get().startPhoneHome();
            }
            DetectorEnvironment detectorEnvironment = new DetectorEnvironment(directoryManager.getSourceDirectory(), Collections.emptySet(), 0, null, false);
            DetectorFactory detectorFactory = detectContext.getBean(DetectorFactory.class);
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.DOCKER)) {
                logger.info("Will include the docker tool.");
                ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createDockerDetector(detectorEnvironment));
                toolRunner.run(runResult);
                logger.info("Docker actions finished.");
            } else {
                logger.info("Docker tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.BAZEL)) {
                logger.info("Will include the bazel tool.");
                ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createBazelDetector(detectorEnvironment));
                toolRunner.run(runResult);
                logger.info("Bazel actions finished.");
            } else {
                logger.info("Bazel tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.DETECTOR)) {
                logger.info("Will include the detector tool.");
                final String projectBomTool = detectConfiguration.getProperty(DetectProperty.DETECT_PROJECT_DETECTOR, PropertyAuthority.None);
                final SearchOptions searchOptions = detectConfigurationFactory.createSearchOptions(directoryManager.getSourceDirectory());
                final DetectorTool detectorTool = new DetectorTool(detectContext);
                final DetectorToolResult detectorToolResult = detectorTool.performDetectors(searchOptions, projectBomTool);
                runResult.addToolNameVersionIfPresent(DetectTool.DETECTOR, detectorToolResult.bomToolProjectNameVersion);
                runResult.addDetectCodeLocations(detectorToolResult.bomToolCodeLocations);
                runResult.addApplicableDetectors(detectorToolResult.applicableDetectorTypes);
                if (detectorToolResult.failedDetectorTypes.size() > 0) {
                    eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_DETECTOR, "A detector failed."));
                }
                logger.info("Detector actions finished.");
            } else {
                logger.info("Detector tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            logger.info("Completed code location tools.");
            logger.info("Determining project info.");
            final ProjectNameVersionOptions projectNameVersionOptions = detectConfigurationFactory.createProjectNameVersionOptions(directoryManager.getSourceDirectory().getName());
            final ProjectNameVersionDecider projectNameVersionDecider = new ProjectNameVersionDecider(projectNameVersionOptions);
            final NameVersion projectNameVersion = projectNameVersionDecider.decideProjectNameVersion(runOptions.getPreferredTools(), runResult.getDetectToolProjectInfo());
            logger.info("Project name: " + projectNameVersion.getName());
            logger.info("Project version: " + projectNameVersion.getVersion());
            Optional<ProjectVersionWrapper> projectVersionWrapper = Optional.empty();
            if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                logger.info("Getting or creating project.");
                final DetectProjectServiceOptions options = detectConfigurationFactory.createDetectProjectServiceOptions();
                final DetectProjectMappingService detectProjectMappingService = new DetectProjectMappingService(blackDuckServicesFactory.createBlackDuckService());
                final DetectProjectService detectProjectService = new DetectProjectService(blackDuckServicesFactory, options, detectProjectMappingService);
                projectVersionWrapper = Optional.of(detectProjectService.createOrUpdateHubProject(projectNameVersion, options.getApplicationId()));
                if (projectVersionWrapper.isPresent() && runOptions.shouldUnmapCodeLocations()) {
                    logger.info("Unmapping code locations.");
                    final DetectCodeLocationUnmapService detectCodeLocationUnmapService = new DetectCodeLocationUnmapService(blackDuckServicesFactory.createBlackDuckService(), blackDuckServicesFactory.createCodeLocationService());
                    detectCodeLocationUnmapService.unmapCodeLocations(projectVersionWrapper.get().getProjectVersionView());
                } else {
                    logger.debug("Will not unmap code locations: Project view was not present, or should not unmap code locations.");
                }
            } else {
                logger.debug("Detect is not online, and will not create the project.");
            }
            logger.info("Completed project and version actions.");
            logger.info("Processing Detect Code Locations.");
            final CodeLocationWaitData codeLocationWaitData = new CodeLocationWaitData();
            final BdioManager bdioManager = new BdioManager(detectInfo, new SimpleBdioFactory(), new IntegrationEscapeUtil(), codeLocationNameManager, detectConfiguration, bdioCodeLocationCreator, directoryManager, eventSystem);
            final BdioResult bdioResult = bdioManager.createBdioFiles(runOptions.getAggregateName(), projectNameVersion, runResult.getDetectCodeLocations());
            if (bdioResult.getUploadTargets().size() > 0) {
                logger.info("Created " + bdioResult.getUploadTargets().size() + " BDIO files.");
                bdioResult.getUploadTargets().forEach(it -> eventSystem.publishEvent(Event.OutputFileOfInterest, it.getUploadFile()));
                if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                    logger.info("Uploading BDIO files.");
                    final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                    final DetectBdioUploadService detectBdioUploadService = new DetectBdioUploadService(detectConfiguration, blackDuckServicesFactory.createBdioUploadService(), eventSystem);
                    final CodeLocationCreationData<UploadBatchOutput> uploadBatchOutputCodeLocationCreationData = detectBdioUploadService.uploadBdioFiles(bdioResult.getUploadTargets());
                    codeLocationWaitData.setFromBdioCodeLocationCreationData(uploadBatchOutputCodeLocationCreationData);
                }
            } else {
                logger.debug("Did not create any BDIO files.");
            }
            logger.info("Completed Detect Code Location processing.");
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN)) {
                logger.info("Will include the signature scanner tool.");
                final BlackDuckSignatureScannerOptions blackDuckSignatureScannerOptions = detectConfigurationFactory.createBlackDuckSignatureScannerOptions();
                final BlackDuckSignatureScannerTool blackDuckSignatureScannerTool = new BlackDuckSignatureScannerTool(blackDuckSignatureScannerOptions, detectContext);
                final SignatureScannerToolResult signatureScannerToolResult = blackDuckSignatureScannerTool.runScanTool(projectNameVersion, runResult.getDockerTar());
                if (signatureScannerToolResult.getResult() == Result.SUCCESS && signatureScannerToolResult.getCreationData().isPresent()) {
                    codeLocationWaitData.setFromSignatureScannerCodeLocationCreationData(signatureScannerToolResult.getCreationData().get());
                }
                logger.info("Signature scanner actions finished.");
            } else {
                logger.info("Signature scan tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.BINARY_SCAN)) {
                logger.info("Will include the binary scanner tool.");
                if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                    final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                    final BlackDuckBinaryScannerTool blackDuckBinaryScanner = new BlackDuckBinaryScannerTool(eventSystem, codeLocationNameManager, detectConfiguration, blackDuckServicesFactory);
                    BinaryScanToolResult result = blackDuckBinaryScanner.performBinaryScanActions(projectNameVersion);
                    if (result.isSuccessful()) {
                        codeLocationWaitData.setFromBinaryScan(result.getNotificationTaskRange(), result.getCodeLocationNames());
                    }
                }
                logger.info("Binary scanner actions finished.");
            } else {
                logger.info("Binary scan tool will not be run.");
            }
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (projectVersionWrapper.isPresent() && connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
                final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
                logger.info("Will perform Black Duck post actions.");
                final BlackduckReportOptions blackduckReportOptions = detectConfigurationFactory.createReportOptions();
                final PolicyCheckOptions policyCheckOptions = detectConfigurationFactory.createPolicyCheckOptions();
                final long timeoutInSeconds = detectConfigurationFactory.getTimeoutInSeconds();
                final BlackduckPostActions blackduckPostActions = new BlackduckPostActions(blackDuckServicesFactory, eventSystem);
                blackduckPostActions.perform(blackduckReportOptions, policyCheckOptions, codeLocationWaitData, projectVersionWrapper.get(), timeoutInSeconds);
                final boolean hasAtLeastOneBdio = !bdioResult.getUploadTargets().isEmpty();
                final boolean shouldHaveScanned = detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN);
                if (hasAtLeastOneBdio || shouldHaveScanned) {
                    final Optional<String> componentsLink = projectVersionWrapper.get().getProjectVersionView().getFirstLink(ProjectVersionView.COMPONENTS_LINK);
                    if (componentsLink.isPresent()) {
                        logger.info(String.format("To see your results, follow the URL: %s", componentsLink.get()));
                    }
                }
                logger.info("Black Duck actions have finished.");
            } else {
                logger.debug("Will not perform post actions: Detect is not online.");
            }
        } else {
            logger.info("Black Duck tools will NOT be run.");
        }
        if (runDecision.willRunPolaris()) {
            logger.info(ReportConstants.RUN_SEPARATOR);
            if (detectToolFilter.shouldInclude(DetectTool.POLARIS)) {
                logger.info("Will include the Polaris tool.");
                final PolarisTool polarisTool = new PolarisTool(eventSystem, directoryManager, new ExecutableRunner(), connectionManager, detectConfiguration);
                polarisTool.runPolaris(new Slf4jIntLogger(logger), directoryManager.getSourceDirectory());
                logger.info("Polaris actions finished.");
            } else {
                logger.info("Polaris CLI tool will not be run.");
            }
        } else {
            logger.info("Polaris tools will NOT be run.");
        }
        logger.info("All tools have finished.");
        logger.info(ReportConstants.RUN_SEPARATOR);
        return runResult;
    }
public runresult run(rundecision rundecision) throws detectuserfriendlyexception, interruptedexception, integrationexception { final detectconfiguration detectconfiguration = detectcontext.getbean(detectconfiguration.class); final detectconfigurationfactory detectconfigurationfactory = detectcontext.getbean(detectconfigurationfactory.class); final directorymanager directorymanager = detectcontext.getbean(directorymanager.class); final eventsystem eventsystem = detectcontext.getbean(eventsystem.class); final codelocationnamemanager codelocationnamemanager = detectcontext.getbean(codelocationnamemanager.class); final bdiocodelocationcreator bdiocodelocationcreator = detectcontext.getbean(bdiocodelocationcreator.class); final connectionmanager connectionmanager = detectcontext.getbean(connectionmanager.class); final detectinfo detectinfo = detectcontext.getbean(detectinfo.class); final runresult runresult = new runresult(); final runoptions runoptions = detectconfigurationfactory.createrunoptions(); final detecttoolfilter detecttoolfilter = runoptions.getdetecttoolfilter(); if (rundecision.willrunblackduck()) { logger.info("black duck tools will run."); final connectivitymanager connectivitymanager = detectcontext.getbean(connectivitymanager.class); if (connectivitymanager.getphonehomemanager().ispresent()) { connectivitymanager.getphonehomemanager().get().startphonehome(); } detectorenvironment detectorenvironment = new detectorenvironment(directorymanager.getsourcedirectory(), collections.emptyset(), 0, null, false); detectorfactory detectorfactory = detectcontext.getbean(detectorfactory.class); logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.docker)) { logger.info("will include the docker tool."); toolrunner toolrunner = new toolrunner(eventsystem, detectorfactory.createdockerdetector(detectorenvironment)); toolrunner.run(runresult); logger.info("docker actions finished."); } else { logger.info("docker tool will not be run."); } logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.bazel)) { logger.info("will include the bazel tool."); toolrunner toolrunner = new toolrunner(eventsystem, detectorfactory.createbazeldetector(detectorenvironment)); toolrunner.run(runresult); logger.info("bazel actions finished."); } else { logger.info("bazel tool will not be run."); } logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.detector)) { logger.info("will include the detector tool."); final string projectbomtool = detectconfiguration.getproperty(detectproperty.detect_project_detector, propertyauthority.none); final searchoptions searchoptions = detectconfigurationfactory.createsearchoptions(directorymanager.getsourcedirectory()); final detectortool detectortool = new detectortool(detectcontext); final detectortoolresult detectortoolresult = detectortool.performdetectors(searchoptions, projectbomtool); runresult.addtoolnameversionifpresent(detecttool.detector, detectortoolresult.bomtoolprojectnameversion); runresult.adddetectcodelocations(detectortoolresult.bomtoolcodelocations); runresult.addapplicabledetectors(detectortoolresult.applicabledetectortypes); if (detectortoolresult.faileddetectortypes.size() > 0) { eventsystem.publishevent(event.exitcode, new exitcoderequest(exitcodetype.failure_detector, "a detector failed.")); } logger.info("detector actions finished."); } else { logger.info("detector tool will not be run."); } logger.info(reportconstants.run_separator); logger.info("completed code location tools."); logger.info("determining project info."); final projectnameversionoptions projectnameversionoptions = detectconfigurationfactory.createprojectnameversionoptions(directorymanager.getsourcedirectory().getname()); final projectnameversiondecider projectnameversiondecider = new projectnameversiondecider(projectnameversionoptions); final nameversion projectnameversion = projectnameversiondecider.decideprojectnameversion(runoptions.getpreferredtools(), runresult.getdetecttoolprojectinfo()); logger.info("project name: " + projectnameversion.getname()); logger.info("project version: " + projectnameversion.getversion()); optional<projectversionwrapper> projectversionwrapper = optional.empty(); if (connectivitymanager.isdetectonline() && connectivitymanager.getblackduckservicesfactory().ispresent()) { final blackduckservicesfactory blackduckservicesfactory = connectivitymanager.getblackduckservicesfactory().get(); logger.info("getting or creating project."); final detectprojectserviceoptions options = detectconfigurationfactory.createdetectprojectserviceoptions(); final detectprojectmappingservice detectprojectmappingservice = new detectprojectmappingservice(blackduckservicesfactory.createblackduckservice()); final detectprojectservice detectprojectservice = new detectprojectservice(blackduckservicesfactory, options, detectprojectmappingservice); projectversionwrapper = optional.of(detectprojectservice.createorupdatehubproject(projectnameversion, options.getapplicationid())); if (projectversionwrapper.ispresent() && runoptions.shouldunmapcodelocations()) { logger.info("unmapping code locations."); final detectcodelocationunmapservice detectcodelocationunmapservice = new detectcodelocationunmapservice(blackduckservicesfactory.createblackduckservice(), blackduckservicesfactory.createcodelocationservice()); detectcodelocationunmapservice.unmapcodelocations(projectversionwrapper.get().getprojectversionview()); } else { logger.debug("will not unmap code locations: project view was not present, or should not unmap code locations."); } } else { logger.debug("detect is not online, and will not create the project."); } logger.info("completed project and version actions."); logger.info("processing detect code locations."); final codelocationwaitdata codelocationwaitdata = new codelocationwaitdata(); final bdiomanager bdiomanager = new bdiomanager(detectinfo, new simplebdiofactory(), new integrationescapeutil(), codelocationnamemanager, detectconfiguration, bdiocodelocationcreator, directorymanager, eventsystem); final bdioresult bdioresult = bdiomanager.createbdiofiles(runoptions.getaggregatename(), projectnameversion, runresult.getdetectcodelocations()); if (bdioresult.getuploadtargets().size() > 0) { logger.info("created " + bdioresult.getuploadtargets().size() + " bdio files."); bdioresult.getuploadtargets().foreach(it -> eventsystem.publishevent(event.outputfileofinterest, it.getuploadfile())); if (connectivitymanager.isdetectonline() && connectivitymanager.getblackduckservicesfactory().ispresent()) { logger.info("uploading bdio files."); final blackduckservicesfactory blackduckservicesfactory = connectivitymanager.getblackduckservicesfactory().get(); final detectbdiouploadservice detectbdiouploadservice = new detectbdiouploadservice(detectconfiguration, blackduckservicesfactory.createbdiouploadservice(), eventsystem); final codelocationcreationdata<uploadbatchoutput> uploadbatchoutputcodelocationcreationdata = detectbdiouploadservice.uploadbdiofiles(bdioresult.getuploadtargets()); codelocationwaitdata.setfrombdiocodelocationcreationdata(uploadbatchoutputcodelocationcreationdata); } } else { logger.debug("did not create any bdio files."); } logger.info("completed detect code location processing."); logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.signature_scan)) { logger.info("will include the signature scanner tool."); final blackducksignaturescanneroptions blackducksignaturescanneroptions = detectconfigurationfactory.createblackducksignaturescanneroptions(); final blackducksignaturescannertool blackducksignaturescannertool = new blackducksignaturescannertool(blackducksignaturescanneroptions, detectcontext); final signaturescannertoolresult signaturescannertoolresult = blackducksignaturescannertool.runscantool(projectnameversion, runresult.getdockertar()); if (signaturescannertoolresult.getresult() == result.success && signaturescannertoolresult.getcreationdata().ispresent()) { codelocationwaitdata.setfromsignaturescannercodelocationcreationdata(signaturescannertoolresult.getcreationdata().get()); } logger.info("signature scanner actions finished."); } else { logger.info("signature scan tool will not be run."); } logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.binary_scan)) { logger.info("will include the binary scanner tool."); if (connectivitymanager.isdetectonline() && connectivitymanager.getblackduckservicesfactory().ispresent()) { final blackduckservicesfactory blackduckservicesfactory = connectivitymanager.getblackduckservicesfactory().get(); final blackduckbinaryscannertool blackduckbinaryscanner = new blackduckbinaryscannertool(eventsystem, codelocationnamemanager, detectconfiguration, blackduckservicesfactory); binaryscantoolresult result = blackduckbinaryscanner.performbinaryscanactions(projectnameversion); if (result.issuccessful()) { codelocationwaitdata.setfrombinaryscan(result.getnotificationtaskrange(), result.getcodelocationnames()); } } logger.info("binary scanner actions finished."); } else { logger.info("binary scan tool will not be run."); } logger.info(reportconstants.run_separator); if (projectversionwrapper.ispresent() && connectivitymanager.isdetectonline() && connectivitymanager.getblackduckservicesfactory().ispresent()) { final blackduckservicesfactory blackduckservicesfactory = connectivitymanager.getblackduckservicesfactory().get(); logger.info("will perform black duck post actions."); final blackduckreportoptions blackduckreportoptions = detectconfigurationfactory.createreportoptions(); final policycheckoptions policycheckoptions = detectconfigurationfactory.createpolicycheckoptions(); final long timeoutinseconds = detectconfigurationfactory.gettimeoutinseconds(); final blackduckpostactions blackduckpostactions = new blackduckpostactions(blackduckservicesfactory, eventsystem); blackduckpostactions.perform(blackduckreportoptions, policycheckoptions, codelocationwaitdata, projectversionwrapper.get(), timeoutinseconds); final boolean hasatleastonebdio = !bdioresult.getuploadtargets().isempty(); final boolean shouldhavescanned = detecttoolfilter.shouldinclude(detecttool.signature_scan); if (hasatleastonebdio || shouldhavescanned) { final optional<string> componentslink = projectversionwrapper.get().getprojectversionview().getfirstlink(projectversionview.components_link); if (componentslink.ispresent()) { logger.info(string.format("to see your results, follow the url: %s", componentslink.get())); } } logger.info("black duck actions have finished."); } else { logger.debug("will not perform post actions: detect is not online."); } } else { logger.info("black duck tools will not be run."); } if (rundecision.willrunpolaris()) { logger.info(reportconstants.run_separator); if (detecttoolfilter.shouldinclude(detecttool.polaris)) { logger.info("will include the polaris tool."); final polaristool polaristool = new polaristool(eventsystem, directorymanager, new executablerunner(), connectionmanager, detectconfiguration); polaristool.runpolaris(new slf4jintlogger(logger), directorymanager.getsourcedirectory()); logger.info("polaris actions finished."); } else { logger.info("polaris cli tool will not be run."); } } else { logger.info("polaris tools will not be run."); } logger.info("all tools have finished."); logger.info(reportconstants.run_separator); return runresult; }