View Javadoc
1   package org.apache.maven.project;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.maven.model.building.ModelProblem;
27  
28  /**
29   * Collects the output of the project builder.
30   * 
31   * @author Benjamin Bentmann
32   */
33  class DefaultProjectBuildingResult
34      implements ProjectBuildingResult
35  {
36  
37      private String projectId;
38  
39      private File pomFile;
40  
41      private MavenProject project;
42  
43      private List<ModelProblem> problems;
44  
45      private DependencyResolutionResult dependencyResolutionResult;
46  
47      /**
48       * Creates a new result with the specified contents.
49       * 
50       * @param project The project that was built, may be {@code null}.
51       * @param problems The problems that were encouterned, may be {@code null}.
52       * @param dependencyResolutionResult The result of the resolution for the project dependencies, may be {@code null}.
53       */
54      public DefaultProjectBuildingResult( MavenProject project, List<ModelProblem> problems,
55                                           DependencyResolutionResult dependencyResolutionResult )
56      {
57          this.projectId =
58              ( project != null ) ? project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion()
59                              : "";
60          this.pomFile = ( project != null ) ? project.getFile() : null;
61          this.project = project;
62          this.problems = problems;
63          this.dependencyResolutionResult = dependencyResolutionResult;
64      }
65  
66      /**
67       * Creates a new result with the specified contents.
68       * 
69       * @param projectId The identifier of the project, may be {@code null}.
70       * @param pomFile The POM file from which the project was built, may be {@code null}.
71       * @param problems The problems that were encouterned, may be {@code null}.
72       */
73      public DefaultProjectBuildingResult( String projectId, File pomFile, List<ModelProblem> problems )
74      {
75          this.projectId = ( projectId != null ) ? projectId : "";
76          this.pomFile = pomFile;
77          this.problems = problems;
78      }
79  
80      public String getProjectId()
81      {
82          return projectId;
83      }
84  
85      public File getPomFile()
86      {
87          return pomFile;
88      }
89  
90      public MavenProject getProject()
91      {
92          return project;
93      }
94  
95      public List<ModelProblem> getProblems()
96      {
97          if ( problems == null )
98          {
99              problems = new ArrayList<ModelProblem>();
100         }
101 
102         return problems;
103     }
104 
105     public DependencyResolutionResult getDependencyResolutionResult()
106     {
107         return dependencyResolutionResult;
108     }
109 
110 }