diff --git a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java index 8f44927c08..bdb08c5664 100644 --- a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java @@ -126,7 +126,7 @@ class RepositoryModelResolver catch ( ArtifactResolutionException e ) { throw new UnresolvableModelException( "Failed to resolve POM for " + groupId + ":" + artifactId + ":" - + version + " due to " + e.getMessage(), e ); + + version + " due to " + e.getMessage(), groupId, artifactId, version, e ); } return new FileModelSource( artifactParent.getFile() ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java index 6d2a0a5724..cfee2da308 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java @@ -30,9 +30,9 @@ class DefaultModelBuildingEvent implements ModelBuildingEvent { - private Model model; + private final Model model; - private ModelBuildingRequest request; + private final ModelBuildingRequest request; public DefaultModelBuildingEvent( Model model, ModelBuildingRequest request ) { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java index e5c50bde3f..5b60d6eb6b 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java @@ -35,7 +35,7 @@ public class ModelBuildingException extends Exception { - private List problems; + private final List problems; /** * Creates a new exception with the specified problems. diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java index a64adb0c15..ad03691c52 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java @@ -41,13 +41,13 @@ public class ModelProblem } - private String source; + private final String source; - private String message; + private final String message; - private Exception exception; + private final Exception exception; - private Severity severity; + private final Severity severity; /** * Creates a new problem with the specified message. @@ -58,9 +58,7 @@ public class ModelProblem */ public ModelProblem( String message, Severity severity, String source ) { - this.message = message; - this.severity = ( severity != null ) ? severity : Severity.ERROR; - this.source = ( source != null ) ? source : ""; + this( message, severity, source, null ); } /** diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java index d16d1f1ef3..234cf66588 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelParseException.java @@ -33,12 +33,12 @@ public class ModelParseException /** * The one-based index of the line containing the error. */ - private int lineNumber; + private final int lineNumber; /** * The one-based index of the column containing the error. */ - private int columnNumber; + private final int columnNumber; /** * Creates a new parser exception with the specified details. diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java index a509d93acb..629e79d199 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java @@ -33,7 +33,7 @@ public class ProfileActivationException /** * The profile which raised this error, can be {@code null}. */ - private Profile profile; + private final Profile profile; /** * Creates a new exception with specified detail message and cause for the given profile. diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java index 04b1fcfd74..aa48fa2586 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/UnresolvableModelException.java @@ -28,25 +28,83 @@ public class UnresolvableModelException extends Exception { + /** + * The group id of the unresolvable model. + */ + private final String groupId; + + /** + * The artifact id of the unresolvable model. + */ + private final String artifactId; + + /** + * The version of the unresolvable model. + */ + private final String version; + /** * Creates a new exception with specified detail message and cause. * * @param message The detail message, may be {@code null}. + * @param groupId The group id of the unresolvable model, may be {@code null}. + * @param artifactId The artifact id of the unresolvable model, may be {@code null}. + * @param version The version of the unresolvable model, may be {@code null}. * @param cause The cause, may be {@code null}. */ - public UnresolvableModelException( String message, Throwable cause ) + public UnresolvableModelException( String message, String groupId, String artifactId, String version, + Throwable cause ) { super( message, cause ); + this.groupId = ( groupId != null ) ? groupId : ""; + this.artifactId = ( artifactId != null ) ? artifactId : ""; + this.version = ( version != null ) ? version : ""; } /** * Creates a new exception with specified detail message. * * @param message The detail message, may be {@code null}. + * @param groupId The group id of the unresolvable model, may be {@code null}. + * @param artifactId The artifact id of the unresolvable model, may be {@code null}. + * @param version The version of the unresolvable model, may be {@code null}. */ - public UnresolvableModelException( String message ) + public UnresolvableModelException( String message, String groupId, String artifactId, String version ) { super( message ); + this.groupId = ( groupId != null ) ? groupId : ""; + this.artifactId = ( artifactId != null ) ? artifactId : ""; + this.version = ( version != null ) ? version : ""; + } + + /** + * Gets the group id of the unresolvable model. + * + * @return The group id of the unresolvable model, can be empty but never {@code null}. + */ + public String getGroupId() + { + return groupId; + } + + /** + * Gets the artifact id of the unresolvable model. + * + * @return The artifact id of the unresolvable model, can be empty but never {@code null}. + */ + public String getArtifactId() + { + return artifactId; + } + + /** + * Gets the version of the unresolvable model. + * + * @return The version of the unresolvable model, can be empty but never {@code null}. + */ + public String getVersion() + { + return version; } }