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 031/** @author Jason van Zyl */ 032public class DefaultMavenExecutionResult 033 implements MavenExecutionResult 034{ 035 private MavenProject project; 036 037 private List<MavenProject> topologicallySortedProjects = Collections.emptyList(); 038 039 private DependencyResolutionResult dependencyResolutionResult; 040 041 private final List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>(); 042 043 private final Map<MavenProject, BuildSummary> buildSummaries = 044 Collections.synchronizedMap( new IdentityHashMap<MavenProject, BuildSummary>() ); 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() 068 : topologicallySortedProjects; 069 } 070 071 public DependencyResolutionResult getDependencyResolutionResult() 072 { 073 return dependencyResolutionResult; 074 } 075 076 public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult ) 077 { 078 this.dependencyResolutionResult = dependencyResolutionResult; 079 080 return this; 081 } 082 083 public List<Throwable> getExceptions() 084 { 085 return exceptions; 086 } 087 088 public MavenExecutionResult addException( Throwable t ) 089 { 090 exceptions.add( t ); 091 092 return this; 093 } 094 095 public boolean hasExceptions() 096 { 097 return !getExceptions().isEmpty(); 098 } 099 100 public BuildSummary getBuildSummary( MavenProject project ) 101 { 102 return buildSummaries.get( project ); 103 } 104 105 public void addBuildSummary( BuildSummary summary ) 106 { 107 buildSummaries.put( summary.getProject(), summary ); 108 } 109}