Search in sources :

Example 1 with ProjectBuilder

use of org.sonar.api.batch.bootstrap.ProjectBuilder 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 ProjectBuilder

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

the class ProjectBuildersExecutorTest method testProjectBuilderFailsWithToString.

@Test
public void testProjectBuilderFailsWithToString() {
    ProjectBuilder builder = mock(ProjectBuilder.class);
    doThrow(new IllegalStateException()).when(builder).build(any(Context.class));
    ProjectBuilder[] projectBuilders = { builder };
    exception.expectMessage("Failed to execute project builder: Mock for ProjectBuilder");
    exception.expect(MessageException.class);
    new ProjectBuildersExecutor(projectBuilders).execute(reactor);
}
Also used : Context(org.sonar.api.batch.bootstrap.ProjectBuilder.Context) ProjectBuilder(org.sonar.api.batch.bootstrap.ProjectBuilder) Test(org.junit.Test)

Aggregations

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