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