View Javadoc
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   * @deprecated use {@code org.apache.maven.api.services.ProjectBuilder} instead
31   */
32  @Deprecated(since = "4.0.0")
33  class DefaultProjectBuildingResult implements ProjectBuildingResult {
34  
35      private final String projectId;
36  
37      private final File pomFile;
38  
39      private final MavenProject project;
40  
41      private final List<ModelProblem> problems;
42  
43      private final DependencyResolutionResult dependencyResolutionResult;
44  
45      /**
46       * Creates a new result with the specified contents.
47       *
48       * @param project The project that was built, may be {@code null}.
49       * @param problems The problems that were encountered, may be {@code null}.
50       * @param dependencyResolutionResult The result of the resolution for the project dependencies, may be {@code null}.
51       */
52      DefaultProjectBuildingResult(
53              MavenProject project, List<ModelProblem> problems, DependencyResolutionResult dependencyResolutionResult) {
54          this.projectId = (project != null)
55                  ? project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion()
56                  : "";
57          this.pomFile = (project != null) ? project.getFile() : null;
58          this.project = project;
59          this.problems = problems != null ? problems : Collections.emptyList();
60          this.dependencyResolutionResult = dependencyResolutionResult;
61      }
62  
63      /**
64       * Creates a new result with the specified contents.
65       *
66       * @param projectId The identifier of the project, may be {@code null}.
67       * @param pomFile The POM file from which the project was built, may be {@code null}.
68       * @param problems The problems that were encountered, may be {@code null}.
69       */
70      DefaultProjectBuildingResult(String projectId, File pomFile, List<ModelProblem> problems) {
71          this.projectId = (projectId != null) ? projectId : "";
72          this.pomFile = pomFile;
73          this.project = null;
74          this.problems = problems != null ? problems : Collections.emptyList();
75          this.dependencyResolutionResult = null;
76      }
77  
78      @Override
79      public String getProjectId() {
80          return projectId;
81      }
82  
83      @Override
84      public File getPomFile() {
85          return pomFile;
86      }
87  
88      @Override
89      public MavenProject getProject() {
90          return project;
91      }
92  
93      @Override
94      public List<ModelProblem> getProblems() {
95          return problems;
96      }
97  
98      @Override
99      public DependencyResolutionResult getDependencyResolutionResult() {
100         return dependencyResolutionResult;
101     }
102 }