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.ArrayList;
23  import java.util.Collections;
24  import java.util.IdentityHashMap;
25  import java.util.List;
26  import java.util.Map;
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;
38  
39      private DependencyResolutionResult dependencyResolutionResult;
40  
41      private List<Throwable> exceptions;
42  
43      private Map<MavenProject, BuildSummary> buildSummaries;
44  
45      public MavenExecutionResult setProject( MavenProject project )
46      {
47          this.project = project;
48  
49          return this;
50      }
51  
52      public MavenProject getProject()
53      {
54          return project;
55      }
56  
57      public MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> topologicallySortedProjects )
58      {
59          this.topologicallySortedProjects = topologicallySortedProjects;
60  
61          return this;
62      }
63  
64      public List<MavenProject> getTopologicallySortedProjects()
65      {
66          return topologicallySortedProjects;
67      }
68  
69      public DependencyResolutionResult getDependencyResolutionResult()
70      {
71          return dependencyResolutionResult;
72      }
73  
74      public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult )
75      {
76          this.dependencyResolutionResult = dependencyResolutionResult;
77  
78          return this;
79      }
80  
81      public List<Throwable> getExceptions()
82      {
83          return exceptions == null ? Collections.<Throwable> emptyList() : exceptions;
84      }
85  
86      public MavenExecutionResult addException( Throwable t )
87      {
88          if ( exceptions == null )
89          {
90              exceptions = new ArrayList<Throwable>();
91          }
92  
93          exceptions.add( t );
94  
95          return this;
96      }
97  
98      public boolean hasExceptions()
99      {
100         return !getExceptions().isEmpty();
101     }
102 
103     public BuildSummary getBuildSummary( MavenProject project )
104     {
105         return ( buildSummaries != null ) ? buildSummaries.get( project ) : null;
106     }
107 
108     public void addBuildSummary( BuildSummary summary )
109     {
110         if ( buildSummaries == null )
111         {
112             buildSummaries = new IdentityHashMap<MavenProject, BuildSummary>();
113         }
114         buildSummaries.put( summary.getProject(), summary );
115     }
116 
117 }