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();
}
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);
}
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));
}
}
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);
}
}
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));
}
Aggregations