1 package org.apache.maven.execution;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collections;
23 import java.util.IdentityHashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.concurrent.CopyOnWriteArrayList;
27
28 import org.apache.maven.project.DependencyResolutionResult;
29 import org.apache.maven.project.MavenProject;
30
31 import com.google.common.collect.Maps;
32
33
34 public class DefaultMavenExecutionResult
35 implements MavenExecutionResult
36 {
37 private MavenProject project;
38
39 private List<MavenProject> topologicallySortedProjects = Collections.emptyList();
40
41 private DependencyResolutionResult dependencyResolutionResult;
42
43 private List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>();
44
45 private Map<MavenProject, BuildSummary> buildSummaries = Maps.newIdentityHashMap();
46
47 public MavenExecutionResult setProject( MavenProject project )
48 {
49 this.project = project;
50
51 return this;
52 }
53
54 public MavenProject getProject()
55 {
56 return project;
57 }
58
59 public MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> topologicallySortedProjects )
60 {
61 this.topologicallySortedProjects = topologicallySortedProjects;
62
63 return this;
64 }
65
66 public List<MavenProject> getTopologicallySortedProjects()
67 {
68 return null == topologicallySortedProjects ? Collections.<MavenProject>emptyList()
69 : topologicallySortedProjects;
70 }
71
72 public DependencyResolutionResult getDependencyResolutionResult()
73 {
74 return dependencyResolutionResult;
75 }
76
77 public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult )
78 {
79 this.dependencyResolutionResult = dependencyResolutionResult;
80
81 return this;
82 }
83
84 public List<Throwable> getExceptions()
85 {
86 return exceptions == null ? Collections.<Throwable>emptyList() : exceptions;
87 }
88
89 public MavenExecutionResult addException( Throwable t )
90 {
91 exceptions.add( t );
92
93 return this;
94 }
95
96 public boolean hasExceptions()
97 {
98 return !getExceptions().isEmpty();
99 }
100
101 public BuildSummary getBuildSummary( MavenProject project )
102 {
103 return ( buildSummaries != null ) ? buildSummaries.get( project ) : null;
104 }
105
106 public void addBuildSummary( BuildSummary summary )
107 {
108 if ( buildSummaries == null )
109 {
110 buildSummaries = new IdentityHashMap<MavenProject, BuildSummary>();
111 }
112 buildSummaries.put( summary.getProject(), summary );
113 }
114 }