Search in sources :

Example 6 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class QualifiersTest method testProject.

@Test
public void testProject() {
    ProjectDefinition rootDef = ProjectDefinition.create();
    ProjectDefinition moduleDef = ProjectDefinition.create();
    rootDef.addSubProject(moduleDef);
    Resource root = new Project(rootDef);
    assertThat(Qualifiers.isView(root, true)).isFalse();
    assertThat(Qualifiers.isView(root, false)).isFalse();
    assertThat(Qualifiers.isProject(root, true)).isTrue();
    assertThat(Qualifiers.isProject(root, false)).isTrue();
}
Also used : ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 7 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ProjectReactorBuilder method execute.

public ProjectReactor execute() {
    Profiler profiler = Profiler.create(LOG).startInfo("Process project properties");
    new DroppedPropertyChecker(analysisProps.properties(), DROPPED_PROPERTIES).checkDroppedProperties();
    Map<String, Map<String, String>> propertiesByModuleIdPath = new HashMap<>();
    extractPropertiesByModule(propertiesByModuleIdPath, "", "", analysisProps.properties());
    ProjectDefinition rootProject = defineRootProject(propertiesByModuleIdPath.get(""), null);
    rootProjectWorkDir = rootProject.getWorkDir();
    defineChildren(rootProject, propertiesByModuleIdPath, "");
    cleanAndCheckProjectDefinitions(rootProject);
    // Since task properties are now empty we should add root module properties
    analysisProps.properties().putAll(propertiesByModuleIdPath.get(""));
    profiler.stopDebug();
    return new ProjectReactor(rootProject);
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) DroppedPropertyChecker(org.sonar.scanner.bootstrap.DroppedPropertyChecker) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Example 8 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ProjectReactorValidator method validate.

public void validate(ProjectReactor reactor) {
    String branch = reactor.getRoot().getBranch();
    List<String> validationMessages = new ArrayList<>();
    checkDeprecatedProperties(validationMessages);
    for (ProjectDefinition moduleDef : reactor.getProjects()) {
        if (mode.isIssues()) {
            validateModuleIssuesMode(moduleDef, validationMessages);
        } else {
            validateModule(moduleDef, validationMessages);
        }
    }
    validateBranch(validationMessages, branch);
    if (!validationMessages.isEmpty()) {
        throw MessageException.of("Validation of project reactor failed:\n  o " + Joiner.on("\n  o ").join(validationMessages));
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Example 9 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class ComponentsPublisher method writeLinks.

private static void writeLinks(InputComponent c, ScannerReport.Component.Builder builder) {
    if (c instanceof InputModule) {
        DefaultInputModule inputModule = (DefaultInputModule) c;
        ProjectDefinition def = inputModule.definition();
        ComponentLink.Builder linkBuilder = ComponentLink.newBuilder();
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_HOME_PAGE, ComponentLinkType.HOME);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_CI, ComponentLinkType.CI);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_ISSUE_TRACKER, ComponentLinkType.ISSUE);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_SOURCES, ComponentLinkType.SCM);
        writeProjectLink(builder, def, linkBuilder, CoreProperties.LINKS_SOURCES_DEV, ComponentLinkType.SCM_DEV);
    }
}
Also used : DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) InputModule(org.sonar.api.batch.fs.InputModule) ComponentLink(org.sonar.scanner.protocol.output.ScannerReport.ComponentLink) DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Example 10 with ProjectDefinition

use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.

the class DefaultIndexTest method createIndex.

@Before
public void createIndex() throws IOException {
    ruleFinder = mock(RuleFinder.class);
    componentStore = mock(InputComponentStore.class);
    componentTree = mock(InputComponentTree.class);
    index = new DefaultIndex(componentStore, componentTree, mock(MeasureCache.class), mock(MetricFinder.class));
    baseDir = temp.newFolder();
    ProjectDefinition rootDef = ProjectDefinition.create().setKey("project").setBaseDir(baseDir);
    ProjectDefinition moduleADef = ProjectDefinition.create().setKey("moduleA").setBaseDir(new java.io.File(baseDir, "moduleA"));
    ProjectDefinition moduleBDef = ProjectDefinition.create().setKey("moduleB").setBaseDir(new java.io.File(baseDir, "moduleB"));
    ProjectDefinition moduleB1Def = ProjectDefinition.create().setKey("moduleB1").setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1"));
    rootDef.addSubProject(moduleADef);
    rootDef.addSubProject(moduleBDef);
    moduleBDef.addSubProject(moduleB1Def);
    project = new Project(rootDef);
    moduleA = new Project(moduleADef);
    moduleB = new Project(moduleBDef);
    moduleB1 = new Project(moduleB1Def);
    RulesProfile rulesProfile = RulesProfile.create();
    rule = Rule.create("repoKey", "ruleKey", "Rule");
    rule.setId(1);
    rulesProfile.activateRule(rule, null);
    index.setCurrentStorage(mock(DefaultSensorStorage.class));
}
Also used : Project(org.sonar.api.resources.Project) RulesProfile(org.sonar.api.profiles.RulesProfile) InputComponentTree(org.sonar.api.batch.fs.internal.InputComponentTree) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) DefaultSensorStorage(org.sonar.scanner.sensor.DefaultSensorStorage) RuleFinder(org.sonar.api.rules.RuleFinder) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Before(org.junit.Before)

Aggregations

ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)52 Test (org.junit.Test)29 File (java.io.File)10 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)8 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)5 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)4 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)4 InputModuleHierarchy (org.sonar.api.batch.fs.internal.InputModuleHierarchy)4 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)4 ProjectAnalysisInfo (org.sonar.scanner.ProjectAnalysisInfo)4 GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)4 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)4 ComponentsPublisher (org.sonar.scanner.report.ComponentsPublisher)4 ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)4 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 Component (org.sonar.scanner.protocol.output.ScannerReport.Component)3 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2