Search in sources :

Example 1 with GlobalAnalysisMode

use of org.sonar.scanner.bootstrap.GlobalAnalysisMode in project sonarqube by SonarSource.

the class SpringProjectScanContainer method doAfterStart.

@Override
protected void doAfterStart() {
    getComponentByType(ProjectLock.class).tryLock();
    GlobalAnalysisMode analysisMode = getComponentByType(GlobalAnalysisMode.class);
    InputModuleHierarchy tree = getComponentByType(InputModuleHierarchy.class);
    ScanProperties properties = getComponentByType(ScanProperties.class);
    properties.validate();
    properties.get("sonar.branch").ifPresent(deprecatedBranch -> {
        throw MessageException.of("The 'sonar.branch' parameter is no longer supported. You should stop using it. " + "Branch analysis is available in Developer Edition and above. See https://redirect.sonarsource.com/editions/developer.html for more information.");
    });
    BranchConfiguration branchConfig = getComponentByType(BranchConfiguration.class);
    if (branchConfig.branchType() == BranchType.PULL_REQUEST) {
        LOG.info("Pull request {} for merge into {} from {}", branchConfig.pullRequestKey(), pullRequestBaseToDisplayName(branchConfig.targetBranchName()), branchConfig.branchName());
    } else if (branchConfig.branchName() != null) {
        LOG.info("Branch name: {}", branchConfig.branchName());
    }
    getComponentByType(ProjectFileIndexer.class).index();
    // Log detected languages and their profiles after FS is indexed and languages detected
    getComponentByType(QProfileVerifier.class).execute();
    scanRecursively(tree, tree.root());
    LOG.info("------------- Run sensors on project");
    getComponentByType(ProjectSensorsExecutor.class).execute();
    getComponentByType(ScmPublisher.class).publish();
    getComponentByType(CpdExecutor.class).execute();
    getComponentByType(ReportPublisher.class).execute();
    if (properties.shouldWaitForQualityGate()) {
        LOG.info("------------- Check Quality Gate status");
        getComponentByType(QualityGateCheck.class).await();
    }
    getComponentByType(PostJobsExecutor.class).execute();
    if (analysisMode.isMediumTest()) {
        getComponentByType(AnalysisObservers.class).notifyEndOfScanTask();
    }
}
Also used : BranchConfiguration(org.sonar.scanner.scan.branch.BranchConfiguration) ProjectFileIndexer(org.sonar.scanner.scan.filesystem.ProjectFileIndexer) GlobalAnalysisMode(org.sonar.scanner.bootstrap.GlobalAnalysisMode) ProjectSensorsExecutor(org.sonar.scanner.sensor.ProjectSensorsExecutor) ReportPublisher(org.sonar.scanner.report.ReportPublisher) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) InputModuleHierarchy(org.sonar.scanner.fs.InputModuleHierarchy) QualityGateCheck(org.sonar.scanner.qualitygate.QualityGateCheck) QProfileVerifier(org.sonar.scanner.rule.QProfileVerifier) ScmPublisher(org.sonar.scanner.scm.ScmPublisher) CpdExecutor(org.sonar.scanner.cpd.CpdExecutor) PostJobsExecutor(org.sonar.scanner.postjob.PostJobsExecutor) AnalysisObservers(org.sonar.scanner.mediumtest.AnalysisObservers)

Aggregations

GlobalAnalysisMode (org.sonar.scanner.bootstrap.GlobalAnalysisMode)1 CpdExecutor (org.sonar.scanner.cpd.CpdExecutor)1 InputModuleHierarchy (org.sonar.scanner.fs.InputModuleHierarchy)1 AnalysisObservers (org.sonar.scanner.mediumtest.AnalysisObservers)1 PostJobsExecutor (org.sonar.scanner.postjob.PostJobsExecutor)1 QualityGateCheck (org.sonar.scanner.qualitygate.QualityGateCheck)1 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)1 ReportPublisher (org.sonar.scanner.report.ReportPublisher)1 QProfileVerifier (org.sonar.scanner.rule.QProfileVerifier)1 BranchConfiguration (org.sonar.scanner.scan.branch.BranchConfiguration)1 ProjectFileIndexer (org.sonar.scanner.scan.filesystem.ProjectFileIndexer)1 ScmPublisher (org.sonar.scanner.scm.ScmPublisher)1 ProjectSensorsExecutor (org.sonar.scanner.sensor.ProjectSensorsExecutor)1