diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index 96748adae2..f1f1fc19aa 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -133,7 +133,7 @@ public class DefaultWagonManager } catch ( UnsupportedProtocolException e ) { - throw new TransferFailedException( "Unsupported Protocol: ", e ); + throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) @@ -156,7 +156,7 @@ public class DefaultWagonManager } catch ( NoSuchAlgorithmException e ) { - throw new TransferFailedException( "Unable to add checksum methods", e ); + throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e ); } try @@ -204,23 +204,23 @@ public class DefaultWagonManager } catch ( ConnectionException e ) { - throw new TransferFailedException( "Connection failed: ", e ); + throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { - throw new TransferFailedException( "Authentication failed: ", e ); + throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { - throw new TransferFailedException( "Authorization failed: ", e ); + throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } catch ( ResourceDoesNotExistException e ) { - throw new TransferFailedException( "Resource to deploy not found: ", e ); + throw new TransferFailedException( "Resource to deploy not found: " + e.getMessage(), e ); } catch ( IOException e ) { - throw new TransferFailedException( "Error creating temporary file for deployment: ", e ); + throw new TransferFailedException( "Error creating temporary file for deployment: " + e.getMessage(), e ); } finally { @@ -320,7 +320,7 @@ public class DefaultWagonManager } catch ( UnsupportedProtocolException e ) { - throw new TransferFailedException( "Unsupported Protocol: ", e ); + throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) @@ -341,7 +341,7 @@ public class DefaultWagonManager } catch ( NoSuchAlgorithmException e ) { - throw new TransferFailedException( "Unable to add checksum methods", e ); + throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e ); } File temp = new File( destination + ".tmp" ); @@ -436,15 +436,15 @@ public class DefaultWagonManager } catch ( ConnectionException e ) { - throw new TransferFailedException( "Connection failed: ", e ); + throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { - throw new TransferFailedException( "Authentication failed: ", e ); + throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { - throw new TransferFailedException( "Authorization failed: ", e ); + throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } finally { @@ -474,7 +474,8 @@ public class DefaultWagonManager } catch ( IOException e ) { - throw new TransferFailedException( "Error copying temporary file to the final destination: ", e ); + throw new TransferFailedException( + "Error copying temporary file to the final destination: " + e.getMessage(), e ); } } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultArtifactTransformationManager.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultArtifactTransformationManager.java index 939f74dc35..69ced76a51 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultArtifactTransformationManager.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultArtifactTransformationManager.java @@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.Iterator; @@ -31,7 +32,7 @@ public class DefaultArtifactTransformationManager private List artifactTransformations; public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException + throws ArtifactResolutionException, ArtifactNotFoundException { for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); ) { diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java index 0ff45bdb0a..a3b58c00e1 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java @@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; @@ -28,7 +29,7 @@ public class LatestArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException + throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) { @@ -37,7 +38,7 @@ public class LatestArtifactTransformation String version = resolveVersion( artifact, localRepository, remoteRepositories ); if ( Artifact.LATEST_VERSION.equals( version ) ) { - throw new ArtifactResolutionException( "Unable to determine the latest version", artifact ); + throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); } artifact.setBaseVersion( version ); diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java index 5488a77838..93c319a274 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java @@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; @@ -36,7 +37,7 @@ public class ReleaseArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException + throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) { @@ -46,7 +47,7 @@ public class ReleaseArtifactTransformation if ( Artifact.RELEASE_VERSION.equals( version ) ) { - throw new ArtifactResolutionException( "Unable to determine the release version", artifact ); + throw new ArtifactNotFoundException( "Unable to determine the release version", artifact ); } artifact.setBaseVersion( version ); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java index 3361e67d82..fce822669e 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.java @@ -19,6 +19,7 @@ package org.apache.maven.artifact.resolver; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -161,7 +162,7 @@ public class AbstractArtifactResolutionException sb.append( "from the specified remote repositories:" ); sb.append( LS + " " ); - for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) + for ( Iterator i = new HashSet( remoteRepositories ).iterator(); i.hasNext(); ) { ArtifactRepository remoteRepository = (ArtifactRepository) i.next(); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java index 6a81982594..441e89365a 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java @@ -29,7 +29,7 @@ public class ArtifactNotFoundException { private String downloadUrl; - protected ArtifactNotFoundException( String message, Artifact artifact ) + public ArtifactNotFoundException( String message, Artifact artifact ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), null, null ); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java index 5100d3d022..b5ebd8b007 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java @@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; @@ -42,7 +43,7 @@ public interface ArtifactTransformation * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException; + throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformationManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformationManager.java index 4271ac46a0..66aa08c016 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformationManager.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformationManager.java @@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; @@ -40,7 +41,7 @@ public interface ArtifactTransformationManager * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) - throws ArtifactResolutionException; + throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java index 8bc4c699cc..c00bf7742a 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java @@ -17,7 +17,6 @@ package org.apache.maven.plugin; */ import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.plugin.Expression; import org.apache.maven.usability.plugin.ExpressionDocumentationException; import org.apache.maven.usability.plugin.ExpressionDocumenter; @@ -273,11 +272,7 @@ public class PluginConfigurationException addParameterUsageInfo( value, message ); } - message.append( "Reason: " ).append( cce.getMessage() ).append( "\n" ); - - Throwable root = DiagnosisUtils.getRootCause( cce ); - - message.append( "Root Cause: " ).append( root.getMessage() ).append( "\n\n" ); + message.append( "\n\nCause: " ).append( cce.getMessage() ); return message.toString(); } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java index 4779140552..f7a33eede2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java @@ -215,8 +215,7 @@ public class DefaultPluginVersionManager // if we still haven't found a version, then fail early before we get into the update goop. if ( StringUtils.isEmpty( version ) ) { - throw new PluginVersionNotFoundException( groupId, artifactId, - "Failed to resolve a valid version for this plugin" ); + throw new PluginVersionNotFoundException( groupId, artifactId ); } // if the plugin registry is inactive, then the rest of this goop is useless... diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java index a40863d432..4b5c613e03 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java @@ -23,9 +23,9 @@ public class PluginVersionNotFoundException private final String artifactId; - public PluginVersionNotFoundException( String groupId, String artifactId, String baseMessage ) + public PluginVersionNotFoundException( String groupId, String artifactId ) { - super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage ); + super( "The plugin \'" + groupId + ":" + artifactId + "\' does not exist or no valid version could be found" ); this.groupId = groupId; this.artifactId = artifactId; diff --git a/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.java index bda97a0e06..a65b4f15d3 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.java @@ -34,8 +34,8 @@ public class ArtifactNotFoundDiagnoser public String diagnose( Throwable error ) { - ArtifactNotFoundException exception = (ArtifactNotFoundException) DiagnosisUtils.getFromCausality( error, - ArtifactNotFoundException.class ); + ArtifactNotFoundException exception = + (ArtifactNotFoundException) DiagnosisUtils.getFromCausality( error, ArtifactNotFoundException.class ); StringBuffer message = new StringBuffer(); @@ -51,13 +51,6 @@ public class ArtifactNotFoundDiagnoser message.append( "\n" ).append( SystemWarnings.getOfflineWarning() ); } - Throwable root = DiagnosisUtils.getRootCause( exception ); - - if ( root != null ) - { - message.append( "\nRoot Cause: " ).append( root.getMessage() ); - } - message.append( "\n" ); return message.toString(); diff --git a/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java index 7454e7798c..6c5bfec95d 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java @@ -34,8 +34,8 @@ public class ArtifactResolverDiagnoser public String diagnose( Throwable error ) { - ArtifactResolutionException exception = (ArtifactResolutionException) DiagnosisUtils.getFromCausality( error, - ArtifactResolutionException.class ); + ArtifactResolutionException exception = + (ArtifactResolutionException) DiagnosisUtils.getFromCausality( error, ArtifactResolutionException.class ); StringBuffer message = new StringBuffer(); @@ -48,13 +48,6 @@ public class ArtifactResolverDiagnoser message.append( "\n" ).append( SystemWarnings.getOfflineWarning() ); } - Throwable root = DiagnosisUtils.getRootCause( exception ); - - if ( root != null ) - { - message.append( "\nRoot Cause: " ).append( root.getMessage() ); - } - message.append( "\n" ); return message.toString(); diff --git a/maven-core/src/main/java/org/apache/maven/usability/InvalidArtifactDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/InvalidArtifactDiagnoser.java index bd3e4b3dd5..0d05a6a4b0 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/InvalidArtifactDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/InvalidArtifactDiagnoser.java @@ -1,8 +1,5 @@ package org.apache.maven.usability; -import org.apache.maven.artifact.InvalidArtifactRTException; -import org.apache.maven.usability.diagnostics.ErrorDiagnoser; - /* * Copyright 2001-2005 The Apache Software Foundation. * @@ -19,6 +16,9 @@ import org.apache.maven.usability.diagnostics.ErrorDiagnoser; * limitations under the License. */ +import org.apache.maven.artifact.InvalidArtifactRTException; +import org.apache.maven.usability.diagnostics.ErrorDiagnoser; + public class InvalidArtifactDiagnoser implements ErrorDiagnoser { @@ -31,25 +31,25 @@ public class InvalidArtifactDiagnoser public String diagnose( Throwable error ) { StringBuffer diagnosis = new StringBuffer(); - + InvalidArtifactRTException e = (InvalidArtifactRTException) error; - + diagnosis.append( "An invalid artifact was detected.\n\n" ) - .append( "This artifact might be in your project's POM, ") - .append( "or it might have been included transitively during the resolution process. ") - .append( "Here is the information we do have for this artifact:\n") - .append( "\n o GroupID: ").append( maybeFlag( e.getGroupId() ) ) - .append( "\n o ArtifactID: ").append( maybeFlag( e.getArtifactId() ) ) - .append( "\n o Version: ").append( maybeFlag( e.getVersion() ) ) - .append( "\n o Type: ").append( maybeFlag( e.getType() ) ) - .append( "\n" ); - + .append( "This artifact might be in your project's POM, " ) + .append( "or it might have been included transitively during the resolution process. " ) + .append( "Here is the information we do have for this artifact:\n" ) + .append( "\n o GroupID: " ).append( maybeFlag( e.getGroupId() ) ) + .append( "\n o ArtifactID: " ).append( maybeFlag( e.getArtifactId() ) ) + .append( "\n o Version: " ).append( maybeFlag( e.getVersion() ) ) + .append( "\n o Type: " ).append( maybeFlag( e.getType() ) ) + .append( "\n" ); + return diagnosis.toString(); } private String maybeFlag( String value ) { - if( value == null || value.trim().length() < 1 ) + if ( value == null || value.trim().length() < 1 ) { return "<<< MISSING >>>"; } diff --git a/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java index 88c16bfd64..0e7d3a4ff7 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java @@ -1,5 +1,21 @@ package org.apache.maven.usability; +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; @@ -15,12 +31,13 @@ public class MojoExecutionExceptionDiagnoser public String diagnose( Throwable error ) { - MojoExecutionException mee = (MojoExecutionException) DiagnosisUtils.getFromCausality( error, MojoExecutionException.class ); - + MojoExecutionException mee = + (MojoExecutionException) DiagnosisUtils.getFromCausality( error, MojoExecutionException.class ); + StringBuffer message = new StringBuffer(); - + message.append( "Error executing mojo" ); - + Object source = mee.getSource(); if ( source != null ) { @@ -30,24 +47,15 @@ public class MojoExecutionExceptionDiagnoser { message.append( ".\n" ); } - - message.append( "\nMessage: " ).append( mee.getMessage() ); - + + message.append( "\n" ).append( mee.getMessage() ); + String longMessage = mee.getLongMessage(); if ( longMessage != null ) { message.append( "\n\n" ).append( longMessage ); } - - Throwable root = DiagnosisUtils.getRootCause( mee ); - - if ( root != null && root != mee ) - { - message.append( "\n\nRoot Cause: " ).append( root.getMessage() ); - } - - message.append( "\n\n" ); - + return message.toString(); } diff --git a/maven-core/src/main/java/org/apache/maven/usability/MojoFailureExceptionDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/MojoFailureExceptionDiagnoser.java new file mode 100644 index 0000000000..629397123f --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/usability/MojoFailureExceptionDiagnoser.java @@ -0,0 +1,60 @@ +package org.apache.maven.usability; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.usability.diagnostics.DiagnosisUtils; +import org.apache.maven.usability.diagnostics.ErrorDiagnoser; + +public class MojoFailureExceptionDiagnoser + implements ErrorDiagnoser +{ + + public boolean canDiagnose( Throwable error ) + { + return DiagnosisUtils.containsInCausality( error, MojoFailureExceptionDiagnoser.class ); + } + + public String diagnose( Throwable error ) + { + MojoFailureException mfe = + (MojoFailureException) DiagnosisUtils.getFromCausality( error, MojoFailureException.class ); + + StringBuffer message = new StringBuffer(); + + Object source = mfe.getSource(); + if ( source != null ) + { + message.append( ": " ).append( mfe.getSource() ).append( "\n" ); + } + else + { + message.append( ".\n" ); + } + + message.append( "\n" ).append( mfe.getMessage() ); + + String longMessage = mfe.getLongMessage(); + if ( longMessage != null ) + { + message.append( "\n\n" ).append( longMessage ); + } + + return message.toString(); + } + +} diff --git a/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java index 89593b9901..935c4adda4 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.java @@ -1,5 +1,21 @@ package org.apache.maven.usability; +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; @@ -16,30 +32,25 @@ public class ProfileActivationDiagnoser public String diagnose( Throwable error ) { - ProfileActivationException activationException = (ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class ); - + ProfileActivationException activationException = + (ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class ); + StringBuffer messageBuffer = new StringBuffer(); - + messageBuffer.append( "Error activating profiles." ); messageBuffer.append( "\n\nReason: " ).append( activationException.getMessage() ); - + if ( DiagnosisUtils.containsInCausality( activationException, ComponentLookupException.class ) ) { - ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality( activationException, ComponentLookupException.class ); - + ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality( + activationException, ComponentLookupException.class ); + messageBuffer.append( "\n\nThere was a problem retrieving one or more profile activators." ); messageBuffer.append( "\n" ).append( cle.getMessage() ); } - - Throwable root = DiagnosisUtils.getRootCause( error ); - - if ( root != null && root != error ) - { - messageBuffer.append( "\n\nRoot Cause: " ).append( root.getMessage() ); - } - + messageBuffer.append( "\n" ); - + return messageBuffer.toString(); } diff --git a/maven-core/src/main/java/org/apache/maven/usability/ProjectBuildDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/ProjectBuildDiagnoser.java index 9a308f5177..ec5122606c 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/ProjectBuildDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/ProjectBuildDiagnoser.java @@ -1,5 +1,21 @@ package org.apache.maven.usability; +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import org.apache.maven.project.InvalidProjectModelException; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.validation.ModelValidationResult; @@ -17,39 +33,33 @@ public class ProjectBuildDiagnoser public String diagnose( Throwable error ) { - ProjectBuildingException pbe = (ProjectBuildingException) DiagnosisUtils.getFromCausality( error, ProjectBuildingException.class ); - + ProjectBuildingException pbe = + (ProjectBuildingException) DiagnosisUtils.getFromCausality( error, ProjectBuildingException.class ); + StringBuffer message = new StringBuffer(); - + message.append( "Error building POM (may not be this project's POM)." ).append( "\n\n" ); - + message.append( "\nProject ID: " ).append( pbe.getProjectId() ); - + if ( pbe instanceof InvalidProjectModelException ) { InvalidProjectModelException ipme = (InvalidProjectModelException) pbe; - + message.append( "\nPOM Location: " ).append( ipme.getPomLocation() ); - + ModelValidationResult result = ipme.getValidationResult(); - + if ( result != null ) { message.append( "\nValidation Messages:\n\n" ).append( ipme.getValidationResult().render( " " ) ); } } - + message.append( "\n\n" ).append( "Reason: " ).append( pbe.getMessage() ); - - Throwable t = DiagnosisUtils.getRootCause( error ); - - if ( t != null && t != pbe ) - { - message.append( "\n" ).append( "Root Cause: " ).append( t.getMessage() ); - } - + message.append( "\n\n" ); - + return message.toString(); } diff --git a/maven-core/src/main/java/org/apache/maven/usability/SystemWarnings.java b/maven-core/src/main/java/org/apache/maven/usability/SystemWarnings.java index c3abec43b9..cb4a810898 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/SystemWarnings.java +++ b/maven-core/src/main/java/org/apache/maven/usability/SystemWarnings.java @@ -1,4 +1,18 @@ -package org.apache.maven.usability; +package org.apache.maven.usability;/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ public class SystemWarnings { @@ -6,7 +20,7 @@ public class SystemWarnings public static String getOfflineWarning() { return "\nNOTE: Maven is executing in offline mode. Any artifacts not already in your local\n" + - "repository will be inaccessible.\n"; + "repository will be inaccessible.\n"; } - + } diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml index f585b5da54..73b9e2de04 100644 --- a/maven-core/src/main/resources/META-INF/plexus/components.xml +++ b/maven-core/src/main/resources/META-INF/plexus/components.xml @@ -102,6 +102,16 @@ + + org.apache.maven.usability.diagnostics.ErrorDiagnoser + MojoFailureExceptionDiagnoser + org.apache.maven.usability.MojoFailureExceptionDiagnoser + + diff --git a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java index 47e36b4e2c..f1ca3c29e3 100644 --- a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java +++ b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java @@ -33,31 +33,31 @@ public class ErrorDiagnostics implements Contextualizable { public static final String ROLE = ErrorDiagnostics.class.getName(); - + private PlexusContainer container; private List errorDiagnosers; - + public void setErrorDiagnosers( List errorDiagnosers ) { this.errorDiagnosers = errorDiagnosers; } - + public String diagnose( Throwable error ) { List diags = errorDiagnosers; - + boolean releaseDiags = false; boolean errorProcessed = false; - + String message = null; - + try { if ( diags == null ) { releaseDiags = true; - + try { diags = container.lookupList( ErrorDiagnoser.ROLE ); @@ -67,7 +67,7 @@ public class ErrorDiagnostics getLogger().error( "Failed to lookup the list of error diagnosers.", e ); } } - + if ( diags != null ) { for ( Iterator it = diags.iterator(); it.hasNext(); ) @@ -98,23 +98,24 @@ public class ErrorDiagnostics getLogger().debug( "Failed to release error diagnoser list.", e ); } } - + if ( !errorProcessed ) { message = new PuntErrorDiagnoser().diagnose( error ); } } - + return message; } - + public void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } - - private static class PuntErrorDiagnoser implements ErrorDiagnoser + + private static class PuntErrorDiagnoser + implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) @@ -125,21 +126,11 @@ public class ErrorDiagnostics public String diagnose( Throwable error ) { StringBuffer message = new StringBuffer(); - - message.append( "Error: " ).append( error.getClass().getName() ); - message.append( "\nMessage: " ).append( error.getMessage() ); - - Throwable root = DiagnosisUtils.getRootCause( error ); - - if ( root != null && root != error ) - { - message.append( "\n\nRoot Cause\n\n" ); - message.append( "Error: " ).append( root.getClass().getName() ); - message.append( "\nMessage: " ).append( root.getMessage() ); - } - + + message.append( error.getMessage() ); + return message.toString(); } - + } } diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index cb4b109b9d..1953e7fbef 100644 --- a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -156,8 +156,7 @@ public class DeployMojo } catch ( ArtifactDeploymentException e ) { - throw new MojoExecutionException( - "Error deploying artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); + throw new MojoExecutionException( e.getMessage(), e ); } } } \ No newline at end of file diff --git a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java index f20be501c5..ef280e8b7b 100644 --- a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java +++ b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java @@ -125,8 +125,7 @@ public class InstallMojo } catch ( ArtifactInstallationException e ) { - throw new MojoExecutionException( - "Error installing artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); + throw new MojoExecutionException( e.getMessage(), e ); } } } diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index c1a7edd4d6..7f5af6bfaa 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -472,7 +472,7 @@ public class DefaultMavenProjectBuilder private Model createStubModel( Artifact projectArtifact ) { - getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact + " *****\n" ); + getLogger().debug( "Using defaults for missing POM " + projectArtifact ); Model model = new Model(); model.setModelVersion( "4.0.0" );