View Javadoc
1   package org.apache.maven.execution;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  /** @author Jason van Zyl */
32  public class DefaultMavenExecutionResult
33      implements MavenExecutionResult
34  {
35      private MavenProject project;
36  
37      private List<MavenProject> topologicallySortedProjects = Collections.emptyList();
38  
39      private DependencyResolutionResult dependencyResolutionResult;
40  
41      private final List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>();
42  
43      private final Map<MavenProject, BuildSummary> buildSummaries =
44          Collections.synchronizedMap( new IdentityHashMap<MavenProject, BuildSummary>() );
45  
46      public MavenExecutionResult setProject( MavenProject project )
47      {
48          this.project = project;
49  
50          return this;
51      }
52  
53      public MavenProject getProject()
54      {
55          return project;
56      }
57  
58      public MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> topologicallySortedProjects )
59      {
60          this.topologicallySortedProjects = topologicallySortedProjects;
61  
62          return this;
63      }
64  
65      public List<MavenProject> getTopologicallySortedProjects()
66      {
67          return null == topologicallySortedProjects ? Collections.<MavenProject>emptyList()
68                          : topologicallySortedProjects;
69      }
70  
71      public DependencyResolutionResult getDependencyResolutionResult()
72      {
73          return dependencyResolutionResult;
74      }
75  
76      public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult )
77      {
78          this.dependencyResolutionResult = dependencyResolutionResult;
79  
80          return this;
81      }
82  
83      public List<Throwable> getExceptions()
84      {
85          return exceptions;
86      }
87  
88      public MavenExecutionResult addException( Throwable t )
89      {
90          exceptions.add( t );
91  
92          return this;
93      }
94  
95      public boolean hasExceptions()
96      {
97          return !getExceptions().isEmpty();
98      }
99  
100     public BuildSummary getBuildSummary( MavenProject project )
101     {
102         return buildSummaries.get( project );
103     }
104 
105     public void addBuildSummary( BuildSummary summary )
106     {
107         buildSummaries.put( summary.getProject(), summary );
108     }
109 }