Search in sources :

Example 1 with ProjectBuilderContext

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

the class ProjectBuildersExecutor method execute.

public void execute(ProjectReactor reactor) {
    if (projectBuilders.length > 0) {
        Profiler profiler = Profiler.create(LOG).startInfo("Execute project builders");
        ProjectBuilderContext context = new ProjectBuilderContext(reactor);
        for (ProjectBuilder projectBuilder : projectBuilders) {
            try {
                projectBuilder.build(context);
            } catch (Exception e) {
                throw MessageException.of("Failed to execute project builder: " + getDescription(projectBuilder), e);
            }
        }
        profiler.stopInfo();
    }
}
Also used : ProjectBuilderContext(org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext) Profiler(org.sonar.api.utils.log.Profiler) ProjectBuilder(org.sonar.api.batch.bootstrap.ProjectBuilder) MessageException(org.sonar.api.utils.MessageException)

Example 2 with ProjectBuilderContext

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

the class ProjectBuilderTest method shouldChangeProject.

@Test
public void shouldChangeProject() {
    // this reactor is created and provided by Sonar
    final ProjectReactor projectReactor = new ProjectReactor(ProjectDefinition.create());
    ProjectBuilder builder = new ProjectBuilderSample(new MapSettings());
    builder.build(new ProjectBuilderContext(projectReactor));
    assertThat(projectReactor.getProjects().size(), is(2));
    ProjectDefinition root = projectReactor.getRoot();
    assertThat(root.getName(), is("Name changed by plugin"));
    assertThat(root.getSubProjects().size(), is(1));
    assertThat(root.getSubProjects().get(0).sources()).contains("src");
}
Also used : ProjectBuilderContext(org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Aggregations

ProjectBuilderContext (org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext)2 Test (org.junit.Test)1 ProjectBuilder (org.sonar.api.batch.bootstrap.ProjectBuilder)1 MapSettings (org.sonar.api.config.MapSettings)1 MessageException (org.sonar.api.utils.MessageException)1 Profiler (org.sonar.api.utils.log.Profiler)1