001    package org.apache.maven.model.building;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.List;
023    
024    import org.apache.maven.model.Model;
025    import org.apache.maven.model.Profile;
026    
027    /**
028     * Collects the output of the model builder.
029     * 
030     * @author Benjamin Bentmann
031     */
032    public interface ModelBuildingResult
033    {
034    
035        /**
036         * Gets the sequence of model identifiers that denote the lineage of models from which the effective model was
037         * constructed. Model identifiers have the form {@code <groupId>:<artifactId>:<version>}. The first identifier from
038         * the list denotes the model on which the model builder was originally invoked. The last identifier will always be
039         * an empty string that by definition denotes the super POM.
040         * 
041         * @return The model identifiers from the lineage of models, never {@code null}.
042         */
043        List<String> getModelIds();
044    
045        /**
046         * Gets the assembled model.
047         * 
048         * @return The assembled model, never {@code null}.
049         */
050        Model getEffectiveModel();
051    
052        /**
053         * Gets the raw model as it was read from the input model source. Apart from basic validation, the raw model has not
054         * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation.
055         * 
056         * @return The raw model, never {@code null}.
057         */
058        Model getRawModel();
059    
060        /**
061         * Gets the specified raw model as it was read from a model source. Apart from basic validation, a raw model has not
062         * undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation. The model
063         * identifier should be from the collection obtained by {@link #getModelIds()}. As a special case, an empty string
064         * can be used as the identifier for the super POM.
065         * 
066         * @param modelId The identifier of the desired raw model, must not be {@code null}.
067         * @return The raw model or {@code null} if the specified model id does not refer to a known model.
068         */
069        Model getRawModel( String modelId );
070    
071        /**
072         * Gets the profiles from the specified model that were active during model building. The model identifier should be
073         * from the collection obtained by {@link #getModelIds()}. As a special case, an empty string can be used as the
074         * identifier for the super POM.
075         * 
076         * @param modelId The identifier of the model whose active profiles should be retrieved, must not be {@code null}.
077         * @return The active profiles of the model or an empty list if none or {@code null} if the specified model id does
078         *         not refer to a known model.
079         */
080        List<Profile> getActivePomProfiles( String modelId );
081    
082        /**
083         * Gets the external profiles that were active during model building. External profiles are those that were
084         * contributed by {@link ModelBuildingRequest#getProfiles()}.
085         * 
086         * @return The active external profiles or an empty list if none, never {@code null}.
087         */
088        List<Profile> getActiveExternalProfiles();
089    
090        /**
091         * Gets the problems that were encountered during the model building. Note that only problems of severity
092         * {@link ModelProblem.Severity#WARNING} and below are reported here. Problems with a higher severity level cause
093         * the model builder to fail with a {@link ModelBuildingException}.
094         * 
095         * @return The problems that were encountered during the model building, can be empty but never {@code null}.
096         */
097        List<ModelProblem> getProblems();
098    
099    }