use of org.sonar.api.batch.fs.internal.AbstractProjectOrModule in project sonarqube by SonarSource.
the class MetadataPublisher method publish.
@Override
public void publish(ScannerReportWriter writer) {
AbstractProjectOrModule rootProject = moduleHierarchy.root();
ScannerReport.Metadata.Builder builder = ScannerReport.Metadata.newBuilder().setAnalysisDate(projectInfo.getAnalysisDate().getTime()).setProjectKey(rootProject.key()).setCrossProjectDuplicationActivated(cpdSettings.isCrossProjectDuplicationEnabled()).setRootComponentRef(rootProject.scannerId());
projectInfo.getProjectVersion().ifPresent(builder::setProjectVersion);
projectInfo.getBuildString().ifPresent(builder::setBuildString);
if (branchConfiguration.branchName() != null) {
addBranchInformation(builder);
}
addScmInformation(builder);
addNotAnalyzedFileCountsByLanguage(builder);
for (QProfile qp : qProfiles.findAll()) {
builder.putQprofilesPerLanguage(qp.getLanguage(), ScannerReport.Metadata.QProfile.newBuilder().setKey(qp.getKey()).setLanguage(qp.getLanguage()).setName(qp.getName()).setRulesUpdatedAt(qp.getRulesUpdatedAt().getTime()).build());
}
for (Entry<String, ScannerPlugin> pluginEntry : pluginRepository.getPluginsByKey().entrySet()) {
builder.putPluginsByKey(pluginEntry.getKey(), ScannerReport.Metadata.Plugin.newBuilder().setKey(pluginEntry.getKey()).setUpdatedAt(pluginEntry.getValue().getUpdatedAt()).build());
}
addModulesRelativePaths(builder);
writer.writeMetadata(builder.build());
}
use of org.sonar.api.batch.fs.internal.AbstractProjectOrModule in project sonarqube by SonarSource.
the class DefaultInputProjectTest method testGetters.
@Test
public void testGetters() throws IOException {
ProjectDefinition def = ProjectDefinition.create();
def.setKey("projectKey");
def.setName("projectName");
File baseDir = temp.newFolder();
def.setBaseDir(baseDir);
def.setDescription("desc");
File workDir = temp.newFolder();
def.setWorkDir(workDir);
def.setSources("file1");
def.setTests("test1");
AbstractProjectOrModule project = new DefaultInputProject(def);
assertThat(project.key()).isEqualTo("projectKey");
assertThat(project.getName()).isEqualTo("projectName");
assertThat(project.getOriginalName()).isEqualTo("projectName");
assertThat(project.definition()).isEqualTo(def);
assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS));
assertThat(project.getDescription()).isEqualTo("desc");
assertThat(project.getWorkDir()).isEqualTo(workDir.toPath());
assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset());
assertThat(project.properties()).hasSize(5);
assertThat(project.isFile()).isFalse();
}
Aggregations