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  import com.google.common.collect.Maps;
32  
33  /** @author Jason van Zyl */
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 }