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, " -> "));
}
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());
}
}
- private void logPostJobs() {
+ private void logPostJobs(Collection<PostJob> postJobs) {
if (LOG.isDebugEnabled()) {
LOG.debug("Post-jobs : {}", StringUtils.join(postJobs, " -> "));
}
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;
}
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) {
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);