aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java17
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java4
4 files changed, 17 insertions, 14 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
index c205df16034..50b0d975170 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersExecutor.java
@@ -39,18 +39,19 @@ public class InitializersExecutor {
private MavenPluginExecutor mavenExecutor;
- private Collection<Initializer> initializers;
private ProjectDefinition projectDef;
private Project project;
+ private BatchExtensionDictionnary selector;
public InitializersExecutor(BatchExtensionDictionnary selector, Project project, ProjectDefinition projectDef, MavenPluginExecutor mavenExecutor) {
- this.initializers = selector.select(Initializer.class, project, true);
+ this.selector = selector;
this.mavenExecutor = mavenExecutor;
this.project = project;
this.projectDef = projectDef;
}
public void execute() {
+ Collection<Initializer> initializers = selector.select(Initializer.class, project, true);
if (logger.isDebugEnabled()) {
logger.debug("Initializers : {}", StringUtils.join(initializers, " -> "));
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
index 3f6b6433cbc..aa5ca9873b9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
@@ -38,24 +38,25 @@ import java.util.List;
public class PostJobsExecutor implements BatchComponent {
private static final Logger LOG = LoggerFactory.getLogger(PostJobsExecutor.class);
- private Collection<PostJob> postJobs;
private MavenPluginExecutor mavenExecutor;
private ProjectDefinition projectDefinition;
private Project project;
+ private BatchExtensionDictionnary selector;
public PostJobsExecutor(BatchExtensionDictionnary selector, Project project, ProjectDefinition projectDefinition, MavenPluginExecutor mavenExecutor) {
- this(selector.select(PostJob.class, project, true), project, projectDefinition, mavenExecutor);
- }
-
- PostJobsExecutor(Collection<PostJob> jobs, Project project, ProjectDefinition projectDefinition, MavenPluginExecutor mavenExecutor) {
- this.postJobs = jobs;
+ this.selector = selector;
this.mavenExecutor = mavenExecutor;
this.project = project;
this.projectDefinition = projectDefinition;
}
public void execute(SensorContext context) {
- logPostJobs();
+ Collection<PostJob> postJobs = selector.select(PostJob.class, project, true);
+ execute(context, postJobs);
+ }
+
+ void execute(SensorContext context, Collection<PostJob> postJobs) {
+ logPostJobs(postJobs);
for (PostJob postJob : postJobs) {
LOG.info("Executing post-job {}", postJob.getClass());
@@ -64,7 +65,7 @@ public class PostJobsExecutor implements BatchComponent {
}
}
- private void logPostJobs() {
+ private void logPostJobs(Collection<PostJob> postJobs) {
if (LOG.isDebugEnabled()) {
LOG.debug("Post-jobs : {}", StringUtils.join(postJobs, " -> "));
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
index f59d9c5fe55..df810a15355 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
@@ -39,14 +39,14 @@ import java.util.Collection;
public class SensorsExecutor implements BatchComponent {
private static final Logger LOG = LoggerFactory.getLogger(SensorsExecutor.class);
- private Collection<Sensor> sensors;
private MavenPluginExecutor mavenExecutor;
private EventBus eventBus;
private Project project;
private ProjectDefinition projectDefinition;
+ private BatchExtensionDictionnary selector;
public SensorsExecutor(BatchExtensionDictionnary selector, Project project, ProjectDefinition projectDefinition, MavenPluginExecutor mavenExecutor, EventBus eventBus) {
- this.sensors = selector.select(Sensor.class, project, true);
+ this.selector = selector;
this.mavenExecutor = mavenExecutor;
this.eventBus = eventBus;
this.project = project;
@@ -54,6 +54,7 @@ public class SensorsExecutor implements BatchComponent {
}
public void execute(SensorContext context) {
+ Collection<Sensor> sensors = selector.select(Sensor.class, project, true);
eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(sensors), true));
for (Sensor sensor : sensors) {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
index 60efff96509..b17c0de0350 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
@@ -42,9 +42,9 @@ public class PostJobsExecutorTest {
Project project = new Project("project");
ProjectDefinition projectDefinition = ProjectDefinition.create();
- PostJobsExecutor executor = new PostJobsExecutor(jobs, project, projectDefinition, mock(MavenPluginExecutor.class));
+ PostJobsExecutor executor = new PostJobsExecutor(null, project, projectDefinition, mock(MavenPluginExecutor.class));
SensorContext context = mock(SensorContext.class);
- executor.execute(context);
+ executor.execute(context, jobs);
verify(job1).executeOn(project, context);
verify(job2).executeOn(project, context);