001 package org.apache.maven.execution;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import java.util.ArrayList;
023 import java.util.Collections;
024 import java.util.IdentityHashMap;
025 import java.util.List;
026 import java.util.Map;
027 import java.util.concurrent.CopyOnWriteArrayList;
028
029 import org.apache.maven.project.DependencyResolutionResult;
030 import org.apache.maven.project.MavenProject;
031
032 /** @author Jason van Zyl */
033 public class DefaultMavenExecutionResult
034 implements MavenExecutionResult
035 {
036 private MavenProject project;
037
038 private List<MavenProject> topologicallySortedProjects = Collections.emptyList();
039
040 private DependencyResolutionResult dependencyResolutionResult;
041
042 private List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>( );
043
044 private Map<MavenProject, BuildSummary> buildSummaries;
045
046 public MavenExecutionResult setProject( MavenProject project )
047 {
048 this.project = project;
049
050 return this;
051 }
052
053 public MavenProject getProject()
054 {
055 return project;
056 }
057
058 public MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> topologicallySortedProjects )
059 {
060 this.topologicallySortedProjects = topologicallySortedProjects;
061
062 return this;
063 }
064
065 public List<MavenProject> getTopologicallySortedProjects()
066 {
067 return null == topologicallySortedProjects ? Collections.<MavenProject> emptyList() : topologicallySortedProjects;
068 }
069
070 public DependencyResolutionResult getDependencyResolutionResult()
071 {
072 return dependencyResolutionResult;
073 }
074
075 public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult )
076 {
077 this.dependencyResolutionResult = dependencyResolutionResult;
078
079 return this;
080 }
081
082 public List<Throwable> getExceptions()
083 {
084 return exceptions == null ? Collections.<Throwable> emptyList() : exceptions;
085 }
086
087 public MavenExecutionResult addException( Throwable t )
088 {
089 exceptions.add( t );
090
091 return this;
092 }
093
094 public boolean hasExceptions()
095 {
096 return !getExceptions().isEmpty();
097 }
098
099 public BuildSummary getBuildSummary( MavenProject project )
100 {
101 return ( buildSummaries != null ) ? buildSummaries.get( project ) : null;
102 }
103
104 public void addBuildSummary( BuildSummary summary )
105 {
106 if ( buildSummaries == null )
107 {
108 buildSummaries = new IdentityHashMap<MavenProject, BuildSummary>();
109 }
110 buildSummaries.put( summary.getProject(), summary );
111 }
112
113 }