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  import org.apache.maven.project.DependencyResolutionResult;
27  import org.apache.maven.project.MavenProject;
28  
29  /** @author Jason van Zyl */
30  public class DefaultMavenExecutionResult implements MavenExecutionResult {
31      private MavenProject project;
32  
33      private List<MavenProject> topologicallySortedProjects = Collections.emptyList();
34  
35      private DependencyResolutionResult dependencyResolutionResult;
36  
37      private final List<Throwable> exceptions = new CopyOnWriteArrayList<>();
38  
39      private final Map<MavenProject, BuildSummary> buildSummaries = Collections.synchronizedMap(new IdentityHashMap<>());
40  
41      private boolean canResume = false;
42  
43      public MavenExecutionResult setProject(MavenProject project) {
44          this.project = project;
45  
46          return this;
47      }
48  
49      public MavenProject getProject() {
50          return project;
51      }
52  
53      public MavenExecutionResult setTopologicallySortedProjects(List<MavenProject> topologicallySortedProjects) {
54          this.topologicallySortedProjects = topologicallySortedProjects;
55  
56          return this;
57      }
58  
59      public List<MavenProject> getTopologicallySortedProjects() {
60          return null == topologicallySortedProjects
61                  ? Collections.emptyList()
62                  : Collections.unmodifiableList(topologicallySortedProjects);
63      }
64  
65      public DependencyResolutionResult getDependencyResolutionResult() {
66          return dependencyResolutionResult;
67      }
68  
69      public MavenExecutionResult setDependencyResolutionResult(DependencyResolutionResult dependencyResolutionResult) {
70          this.dependencyResolutionResult = dependencyResolutionResult;
71  
72          return this;
73      }
74  
75      public List<Throwable> getExceptions() {
76          return exceptions;
77      }
78  
79      public MavenExecutionResult addException(Throwable t) {
80          exceptions.add(t);
81  
82          return this;
83      }
84  
85      public boolean hasExceptions() {
86          return !getExceptions().isEmpty();
87      }
88  
89      public BuildSummary getBuildSummary(MavenProject project) {
90          return buildSummaries.get(project);
91      }
92  
93      public void addBuildSummary(BuildSummary summary) {
94          buildSummaries.put(summary.getProject(), summary);
95      }
96  
97      @Override
98      public boolean canResume() {
99          return canResume;
100     }
101 
102     @Override
103     public void setCanResume(boolean canResume) {
104         this.canResume = canResume;
105     }
106 }