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 /** 023 * Describes a problem that was encountered during model building. A problem can either be an exception that was thrown 024 * or a simple string message. In addition, a problem carries a hint about its source, e.g. the POM file that exhibits 025 * the problem. 026 * 027 * @author Benjamin Bentmann 028 */ 029 public interface ModelProblem 030 { 031 032 /** 033 * The different severity levels for a problem, in decreasing order. 034 */ 035 enum Severity 036 { 037 038 FATAL, // 039 ERROR, // 040 WARNING; // 041 042 } 043 044 enum Version { 045 //based on ModeBuildingResult.validationLevel 046 BASE, 047 V20, 048 V30, 049 V31 050 } 051 052 /** 053 * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the 054 * creator of the problem, the general expectation is that the hint provides sufficient information to the user to 055 * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from 056 * which a POM was read. 057 * 058 * @return The hint about the source of the problem or an empty string if unknown, never {@code null}. 059 */ 060 String getSource(); 061 062 /** 063 * Gets the one-based index of the line containing the problem. The line number should refer to some text file that 064 * is given by {@link #getSource()}. 065 * 066 * @return The one-based index of the line containing the problem or a non-positive value if unknown. 067 */ 068 int getLineNumber(); 069 070 /** 071 * Gets the one-based index of the column containing the problem. The column number should refer to some text file 072 * that is given by {@link #getSource()}. 073 * 074 * @return The one-based index of the column containing the problem or non-positive value if unknown. 075 */ 076 int getColumnNumber(); 077 078 /** 079 * Gets the identifier of the model from which the problem originated. While the general form of this identifier is 080 * <code>groupId:artifactId:version</code> the returned identifier need not be complete. The identifier is derived 081 * from the information that is available at the point the problem occurs and as such merely serves as a best effort 082 * to provide information to the user to track the problem back to its origin. 083 * 084 * @return The identifier of the model from which the problem originated or an empty string if unknown, never 085 * {@code null}. 086 */ 087 String getModelId(); 088 089 /** 090 * Gets the exception that caused this problem (if any). 091 * 092 * @return The exception that caused this problem or {@code null} if not applicable. 093 */ 094 Exception getException(); 095 096 /** 097 * Gets the message that describes this problem. 098 * 099 * @return The message describing this problem, never {@code null}. 100 */ 101 String getMessage(); 102 103 /** 104 * Gets the severity level of this problem. 105 * 106 * @return The severity level of this problem, never {@code null}. 107 */ 108 Severity getSeverity(); 109 110 /** 111 * Gets the applicable maven version/validation level of this problem 112 * @return The version, never {@code null}. 113 */ 114 Version getVersion(); 115 116 }