From 23ec161a179138d5496a6f2f945fda0a81a15f1d Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 8 Sep 2006 14:53:27 +0000 Subject: [PATCH] [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 --- .../DependencyArtifactReportProcessor.java | 18 ++++++++++++++++-- .../DependencyArtifactReportProcessorTest.java | 9 +++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) 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"; } } -- 2.39.5