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;
20
21 import java.util.Collection;
22 import java.util.Collections;
23 import java.util.HashSet;
24
25 import org.apache.maven.execution.ProjectDependencyGraph;
26 import org.apache.maven.lifecycle.internal.builder.BuilderCommon;
27 import org.apache.maven.project.MavenProject;
28
29
30
31
32
33
34 public class ReactorBuildStatus {
35 private final ProjectDependencyGraph projectDependencyGraph;
36
37 private final Collection<String> blackListedProjects = Collections.synchronizedSet(new HashSet<>());
38
39 private volatile boolean halted = false;
40
41 public ReactorBuildStatus(ProjectDependencyGraph projectDependencyGraph) {
42 this.projectDependencyGraph = projectDependencyGraph;
43 }
44
45 public boolean isBlackListed(MavenProject project) {
46 return blackListedProjects.contains(BuilderCommon.getKey(project));
47 }
48
49 public void blackList(MavenProject project) {
50 if (blackListedProjects.add(BuilderCommon.getKey(project)) && projectDependencyGraph != null) {
51 for (MavenProject downstreamProject : projectDependencyGraph.getDownstreamProjects(project, true)) {
52 blackListedProjects.add(BuilderCommon.getKey(downstreamProject));
53 }
54 }
55 }
56
57 public void halt() {
58 halted = true;
59 }
60
61 public boolean isHalted() {
62 return halted;
63 }
64
65 public boolean isHaltedOrBlacklisted(MavenProject mavenProject) {
66 return isBlackListed(mavenProject) || isHalted();
67 }
68 }