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.project;
20
21 import java.io.File;
22 import java.util.Collections;
23 import java.util.List;
24
25 import org.apache.maven.model.building.ModelProblem;
26
27 /**
28 * Collects the output of the project builder.
29 *
30 */
31 class DefaultProjectBuildingResult implements ProjectBuildingResult {
32
33 private final String projectId;
34
35 private final File pomFile;
36
37 private final MavenProject project;
38
39 private final List<ModelProblem> problems;
40
41 private final DependencyResolutionResult dependencyResolutionResult;
42
43 /**
44 * Creates a new result with the specified contents.
45 *
46 * @param project The project that was built, may be {@code null}.
47 * @param problems The problems that were encountered, may be {@code null}.
48 * @param dependencyResolutionResult The result of the resolution for the project dependencies, may be {@code null}.
49 */
50 DefaultProjectBuildingResult(
51 MavenProject project, List<ModelProblem> problems, DependencyResolutionResult dependencyResolutionResult) {
52 this.projectId = (project != null)
53 ? project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion()
54 : "";
55 this.pomFile = (project != null) ? project.getFile() : null;
56 this.project = project;
57 this.problems = problems != null ? problems : Collections.emptyList();
58 this.dependencyResolutionResult = dependencyResolutionResult;
59 }
60
61 /**
62 * Creates a new result with the specified contents.
63 *
64 * @param projectId The identifier of the project, may be {@code null}.
65 * @param pomFile The POM file from which the project was built, may be {@code null}.
66 * @param problems The problems that were encountered, may be {@code null}.
67 */
68 DefaultProjectBuildingResult(String projectId, File pomFile, List<ModelProblem> problems) {
69 this.projectId = (projectId != null) ? projectId : "";
70 this.pomFile = pomFile;
71 this.project = null;
72 this.problems = problems != null ? problems : Collections.emptyList();
73 this.dependencyResolutionResult = null;
74 }
75
76 public String getProjectId() {
77 return projectId;
78 }
79
80 public File getPomFile() {
81 return pomFile;
82 }
83
84 public MavenProject getProject() {
85 return project;
86 }
87
88 public List<ModelProblem> getProblems() {
89 return problems;
90 }
91
92 public DependencyResolutionResult getDependencyResolutionResult() {
93 return dependencyResolutionResult;
94 }
95 }