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.model;
20  
21  import org.apache.maven.api.model.Model;
22  import org.apache.maven.api.services.ModelProblemCollector;
23  
24  /**
25   * Checks the model for missing or invalid values.
26   *
27   */
28  public interface ModelValidator {
29      /**
30       * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories
31       * during metadata retrieval.
32       */
33      int VALIDATION_LEVEL_MINIMAL = 0;
34      /**
35       * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow
36       * users to migrate their projects.
37       */
38      int VALIDATION_LEVEL_MAVEN_2_0 = 20;
39      /**
40       * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects.
41       */
42      int VALIDATION_LEVEL_MAVEN_3_0 = 30;
43      /**
44       * Denotes validation as performed by Maven 3.1. This validation level is meant for existing projects.
45       */
46      int VALIDATION_LEVEL_MAVEN_3_1 = 31;
47      /**
48       * Denotes validation as performed by Maven 4.0. This validation level is meant for new projects.
49       */
50      int VALIDATION_LEVEL_MAVEN_4_0 = 40;
51      /**
52       * Denotes strict validation as recommended by the current Maven version.
53       */
54      int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_4_0;
55  
56      /**
57       * Checks the specified file model for missing or invalid values. This model is directly created from the POM
58       * file and has not been subjected to inheritance, interpolation or profile/default injection.
59       *
60       * @param model The model to validate, must not be {@code null}.
61       * @param validationLevel The validation level.
62       * @param problems The container used to collect problems that were encountered, must not be {@code null}.
63       */
64      void validateFileModel(Model model, int validationLevel, ModelProblemCollector problems);
65  
66      /**
67       * Checks the specified (raw) model for missing or invalid values. The raw model is the file model + buildpom filter
68       * transformation and has not been subjected to inheritance, interpolation or profile/default injection.
69       *
70       * @param model The model to validate, must not be {@code null}.
71       * @param validationLevel The validation level.
72       * @param problems The container used to collect problems that were encountered, must not be {@code null}.
73       */
74      void validateRawModel(Model model, int validationLevel, ModelProblemCollector problems);
75  
76      /**
77       * Checks the specified (effective) model for missing or invalid values. The effective model is fully assembled and
78       * has undergone inheritance, interpolation and other model operations.
79       *
80       * @param model The model to validate, must not be {@code null}.
81       * @param validationLevel The validation level.
82       * @param problems The container used to collect problems that were encountered, must not be {@code null}.
83       */
84      void validateEffectiveModel(Model model, int validationLevel, ModelProblemCollector problems);
85  }