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.model.building;
20  
21  import java.util.List;
22  
23  import org.apache.maven.model.Model;
24  import org.apache.maven.model.Profile;
25  
26  /**
27   * Collects the output of the model builder.
28   *
29   * @author Benjamin Bentmann
30   */
31  public interface ModelBuildingResult {
32  
33      /**
34       * Gets the sequence of model identifiers that denote the lineage of models from which the effective model was
35       * constructed. Model identifiers have the form {@code <groupId>:<artifactId>:<version>}. The first identifier from
36       * the list denotes the model on which the model builder was originally invoked. The last identifier will always be
37       * an empty string that by definition denotes the super POM.
38       *
39       * @return The model identifiers from the lineage of models, never {@code null}.
40       */
41      List<String> getModelIds();
42  
43      /**
44       *
45       * @return the file model
46       * @since 4.0.0
47       */
48      Model getFileModel();
49  
50      /**
51       * Gets the assembled model.
52       *
53       * @return The assembled model, never {@code null}.
54       */
55      Model getEffectiveModel();
56  
57      /**
58       * Gets the raw model as it was read from the input model source. Apart from basic validation, the raw model has not
59       * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation.
60       *
61       * @return The raw model, never {@code null}.
62       */
63      Model getRawModel();
64  
65      /**
66       * Gets the specified raw model as it was read from a model source. Apart from basic validation, a raw model has not
67       * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation. The model
68       * identifier should be from the collection obtained by {@link #getModelIds()}. As a special case, an empty string
69       * can be used as the identifier for the super POM.
70       *
71       * @param modelId The identifier of the desired raw model, must not be {@code null}.
72       * @return The raw model or {@code null} if the specified model id does not refer to a known model.
73       */
74      Model getRawModel(String modelId);
75  
76      /**
77       * Gets the profiles from the specified model that were active during model building. The model identifier should be
78       * from the collection obtained by {@link #getModelIds()}. As a special case, an empty string can be used as the
79       * identifier for the super POM.
80       *
81       * @param modelId The identifier of the model whose active profiles should be retrieved, must not be {@code null}.
82       * @return The active profiles of the model or an empty list if none or {@code null} if the specified model id does
83       *         not refer to a known model.
84       */
85      List<Profile> getActivePomProfiles(String modelId);
86  
87      /**
88       * Gets the external profiles that were active during model building. External profiles are those that were
89       * contributed by {@link ModelBuildingRequest#getProfiles()}.
90       *
91       * @return The active external profiles or an empty list if none, never {@code null}.
92       */
93      List<Profile> getActiveExternalProfiles();
94  
95      /**
96       * Gets the problems that were encountered during the model building. Note that only problems of severity
97       * {@link ModelProblem.Severity#WARNING} and below are reported here. Problems with a higher severity level cause
98       * the model builder to fail with a {@link ModelBuildingException}.
99       *
100      * @return The problems that were encountered during the model building, can be empty but never {@code null}.
101      */
102     List<ModelProblem> getProblems();
103 }