001package 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 022import java.util.Collections; 023import java.util.IdentityHashMap; 024import java.util.List; 025import java.util.Map; 026import java.util.concurrent.CopyOnWriteArrayList; 027 028import org.apache.maven.project.DependencyResolutionResult; 029import org.apache.maven.project.MavenProject; 030 031import com.google.common.collect.Maps; 032 033/** @author Jason van Zyl */ 034public class DefaultMavenExecutionResult 035 implements MavenExecutionResult 036{ 037 private MavenProject project; 038 039 private List<MavenProject> topologicallySortedProjects = Collections.emptyList(); 040 041 private DependencyResolutionResult dependencyResolutionResult; 042 043 private List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>(); 044 045 private Map<MavenProject, BuildSummary> buildSummaries = Maps.newIdentityHashMap(); 046 047 public MavenExecutionResult setProject( MavenProject project ) 048 { 049 this.project = project; 050 051 return this; 052 } 053 054 public MavenProject getProject() 055 { 056 return project; 057 } 058 059 public MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> topologicallySortedProjects ) 060 { 061 this.topologicallySortedProjects = topologicallySortedProjects; 062 063 return this; 064 } 065 066 public List<MavenProject> getTopologicallySortedProjects() 067 { 068 return null == topologicallySortedProjects ? Collections.<MavenProject> emptyList() 069 : topologicallySortedProjects; 070 } 071 072 public DependencyResolutionResult getDependencyResolutionResult() 073 { 074 return dependencyResolutionResult; 075 } 076 077 public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult ) 078 { 079 this.dependencyResolutionResult = dependencyResolutionResult; 080 081 return this; 082 } 083 084 public List<Throwable> getExceptions() 085 { 086 return exceptions == null ? Collections.<Throwable> emptyList() : exceptions; 087 } 088 089 public MavenExecutionResult addException( Throwable t ) 090 { 091 exceptions.add( t ); 092 093 return this; 094 } 095 096 public boolean hasExceptions() 097 { 098 return !getExceptions().isEmpty(); 099 } 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}