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.api.services;
20  
21  import java.util.List;
22  import java.util.Optional;
23  
24  import org.apache.maven.api.annotations.Experimental;
25  import org.apache.maven.api.annotations.Nonnull;
26  import org.apache.maven.api.model.Model;
27  import org.apache.maven.api.model.Profile;
28  
29  /**
30   * Result of a project build call.
31   *
32   * @since 4.0.0
33   */
34  @Experimental
35  public interface ModelBuilderResult {
36  
37      /**
38       * Gets the sequence of model identifiers that denote the lineage of models from which the effective model was
39       * constructed. Model identifiers have the form {@code <groupId>:<artifactId>:<version>}. The first identifier from
40       * the list denotes the model on which the model builder was originally invoked. The last identifier will always be
41       * an empty string that by definition denotes the super POM.
42       *
43       * @return The model identifiers from the lineage of models, never {@code null}.
44       */
45      @Nonnull
46      List<String> getModelIds();
47  
48      /**
49       * Gets the file model.
50       *
51       * @return the file model, never {@code null}.
52       */
53      @Nonnull
54      Model getFileModel();
55  
56      /**
57       * Returns the file model + profile injection.
58       *
59       * @return the activated file model, never {@code null}.
60       */
61      @Nonnull
62      Model getActivatedFileModel();
63  
64      /**
65       * Gets the file model + build pom transformation, without inheritance nor interpolation.
66       *
67       * @return The raw model, never {@code null}.
68       */
69      @Nonnull
70      Model getRawModel();
71  
72      /**
73       * Gets the assembled model with inheritance, interpolation and profile injection.
74       *
75       * @return The assembled model, never {@code null}.
76       */
77      @Nonnull
78      Model getEffectiveModel();
79  
80      /**
81       * Gets the specified raw model as it was read from a model source. Apart from basic validation, a raw model has not
82       * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation. The model
83       * identifier should be from the collection obtained by {@link #getModelIds()}. As a special case, an empty string
84       * can be used as the identifier for the super POM.
85       *
86       * @param modelId The identifier of the desired raw model, must not be {@code null}.
87       * @return The raw model or {@code null} if the specified model id does not refer to a known model.
88       */
89      @Nonnull
90      Optional<Model> getRawModel(@Nonnull String modelId);
91  
92      /**
93       * Gets the profiles from the specified model that were active during model building. The model identifier should be
94       * from the collection obtained by {@link #getModelIds()}. As a special case, an empty string can be used as the
95       * identifier for the super POM.
96       *
97       * @param modelId The identifier of the model whose active profiles should be retrieved, must not be {@code null}.
98       * @return The active profiles of the model or an empty list if the specified model id does
99       *         not refer to a known model or has no active profiles.
100      */
101     @Nonnull
102     List<Profile> getActivePomProfiles(@Nonnull String modelId);
103 
104     /**
105      * Gets the external profiles that were active during model building. External profiles are those that were
106      * contributed by {@link ModelBuilderRequest#getProfiles()}.
107      *
108      * @return The active external profiles or an empty list if none, never {@code null}.
109      */
110     @Nonnull
111     List<Profile> getActiveExternalProfiles();
112 
113     /**
114      * Gets the problems that were encountered during the project building.
115      *
116      * @return the problems that were encountered during the project building, can be empty but never {@code null}
117      */
118     @Nonnull
119     List<ModelProblem> getProblems();
120 
121     /**
122      * Creates a human readable representation of these errors.
123      */
124     String toString();
125 }