1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.lifecycle.internal.builder.singlethreaded;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import java.util.List;
26
27 import org.apache.maven.execution.MavenSession;
28 import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder;
29 import org.apache.maven.lifecycle.internal.ProjectBuildList;
30 import org.apache.maven.lifecycle.internal.ProjectSegment;
31 import org.apache.maven.lifecycle.internal.ReactorBuildStatus;
32 import org.apache.maven.lifecycle.internal.ReactorContext;
33 import org.apache.maven.lifecycle.internal.TaskSegment;
34 import org.apache.maven.lifecycle.internal.builder.Builder;
35
36
37
38
39
40
41 @Named("singlethreaded")
42 @Singleton
43 public class SingleThreadedBuilder implements Builder {
44 private final LifecycleModuleBuilder lifecycleModuleBuilder;
45
46 @Inject
47 public SingleThreadedBuilder(LifecycleModuleBuilder lifecycleModuleBuilder) {
48 this.lifecycleModuleBuilder = lifecycleModuleBuilder;
49 }
50
51 public void build(
52 MavenSession session,
53 ReactorContext reactorContext,
54 ProjectBuildList projectBuilds,
55 List<TaskSegment> taskSegments,
56 ReactorBuildStatus reactorBuildStatus) {
57 for (TaskSegment taskSegment : taskSegments) {
58 for (ProjectSegment projectBuild : projectBuilds.getByTaskSegment(taskSegment)) {
59 try {
60 lifecycleModuleBuilder.buildProject(
61 session, reactorContext, projectBuild.getProject(), taskSegment);
62 if (reactorBuildStatus.isHalted()) {
63 break;
64 }
65 } catch (Exception e) {
66 break;
67 }
68 }
69 }
70 }
71 }