use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class AnalysisContextReportPublisher method collectModuleSpecificProps.
/**
* Only keep props that are not in parent
*/
private Map<String, String> collectModuleSpecificProps(ProjectDefinition moduleDefinition) {
Map<String, String> moduleSpecificProps = new HashMap<>();
if (projectRepos.moduleExists(moduleDefinition.getKeyWithBranch())) {
moduleSpecificProps.putAll(projectRepos.settings(moduleDefinition.getKeyWithBranch()));
}
ProjectDefinition parent = moduleDefinition.getParent();
if (parent == null) {
moduleSpecificProps.putAll(moduleDefinition.properties());
} else {
Map<String, String> parentProps = parent.properties();
for (Map.Entry<String, String> entry : moduleDefinition.properties().entrySet()) {
if (!parentProps.containsKey(entry.getKey()) || !parentProps.get(entry.getKey()).equals(entry.getValue())) {
moduleSpecificProps.put(entry.getKey(), entry.getValue());
}
}
}
return moduleSpecificProps;
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ComponentsPublisher method writeVersion.
private static void writeVersion(DefaultInputModule module, ScannerReport.Component.Builder builder) {
ProjectDefinition def = module.definition();
String version = getVersion(def);
if (version != null) {
builder.setVersion(version);
}
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ProjectReactorBuilder method defineChildren.
private void defineChildren(ProjectDefinition parentProject, Map<String, Map<String, String>> propertiesByModuleIdPath, String parentModuleIdPath) {
Map<String, String> parentProps = parentProject.properties();
if (parentProps.containsKey(PROPERTY_MODULES)) {
for (String moduleId : getListFromProperty(parentProps, PROPERTY_MODULES)) {
String moduleIdPath = parentModuleIdPath.isEmpty() ? moduleId : (parentModuleIdPath + "." + moduleId);
Map<String, String> moduleProps = propertiesByModuleIdPath.get(moduleIdPath);
ProjectDefinition childProject = loadChildProject(parentProject, moduleProps, moduleId);
// check the uniqueness of the child key
checkUniquenessOfChildKey(childProject, parentProject);
// the child project may have children as well
defineChildren(childProject, propertiesByModuleIdPath, moduleIdPath);
// and finally add this child project to its parent
parentProject.addSubProject(childProject);
}
}
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class DefaultInputModuleHierarchy method relativePath.
@Override
@CheckForNull
public String relativePath(InputModule module) {
DefaultInputModule parent = parent(module);
if (parent == null) {
return null;
}
DefaultInputModule inputModule = (DefaultInputModule) module;
ProjectDefinition parentDefinition = parent.definition();
Path parentBaseDir = parentDefinition.getBaseDir().toPath();
ProjectDefinition moduleDefinition = inputModule.definition();
Path moduleBaseDir = moduleDefinition.getBaseDir().toPath();
return pathResolver.relativePath(parentBaseDir, moduleBaseDir);
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ModuleIndexer method createChildren.
private void createChildren(DefaultInputModule parent) {
for (ProjectDefinition def : parent.definition().getSubProjects()) {
DefaultInputModule child = new DefaultInputModule(def, batchIdGenerator.get());
moduleHierarchy.index(child, parent);
componentTree.index(child, parent);
componentStore.put(child);
createChildren(child);
}
}
Aggregations