From: Brett Porter Date: Fri, 8 Sep 2006 14:53:27 +0000 (+0000) Subject: [MRM-77] improve display of dependency errors X-Git-Tag: archiva-0.9-alpha-1~577 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=23ec161a179138d5496a6f2f945fda0a81a15f1d;p=archiva.git [MRM-77] improve display of dependency errors git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441523 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java index ba8e1e8f0..0226b9131 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java @@ -86,14 +86,14 @@ public class DependencyArtifactReportProcessor { String reason = MessageFormat.format( "Artifact''s dependency {0} does not exist in the repository", - new String[]{dependency.toString()} ); + new String[]{getDependencyString( dependency )} ); reporter.addFailure( sourceArtifact, reason ); } } catch ( InvalidVersionSpecificationException e ) { String reason = MessageFormat.format( "Artifact''s dependency {0} contains an invalid version {1}", - new String[]{dependency.toString(), + new String[]{getDependencyString( dependency ), dependency.getVersion()} ); reporter.addFailure( sourceArtifact, reason ); } @@ -101,6 +101,20 @@ public class DependencyArtifactReportProcessor } } + static String getDependencyString( Dependency dependency ) + { + String str = "(group=" + dependency.getGroupId(); + str += ", artifact=" + dependency.getArtifactId(); + str += ", version=" + dependency.getVersion(); + str += ", type=" + dependency.getType(); + if ( dependency.getClassifier() != null ) + { + str += ", classifier=" + dependency.getClassifier(); + } + str += ")"; + return str; + } + private Artifact createArtifact( Dependency dependency ) throws InvalidVersionSpecificationException { diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java index ddc88646e..ae7edc2d1 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java @@ -243,11 +243,16 @@ public class DependencyArtifactReportProcessorTest private String getDependencyVersionInvalidMessage( Dependency dependency, String version ) { - return "Artifact's dependency " + dependency + " contains an invalid version " + version; + return "Artifact's dependency " + getDependencyString( dependency ) + " contains an invalid version " + version; + } + + private static String getDependencyString( Dependency dependency ) + { + return DependencyArtifactReportProcessor.getDependencyString( dependency ); } private String getDependencyNotFoundMessage( Dependency dependency ) { - return "Artifact's dependency " + dependency.toString() + " does not exist in the repository"; + return "Artifact's dependency " + getDependencyString( dependency ) + " does not exist in the repository"; } }