Commits

Samuel Le Berrigaud  committed abd3cd0

- Added dependency trail to report.

  • Participants
  • Parent commits 07854d7

Comments (0)

Files changed (3)

File src/main/groovy/com/atlassian/maven/plugins/AbstractMapMojo.groovy

     SortedSet<DependencyReportLine> reportLines()
     {
         final SortedSet report = new TreeSet()
-        project.dependencyArtifacts.each { report.add(DependencyReportLine.from(it, md5(it))) }
+        project.artifacts.each { report.add(DependencyReportLine.from(it, md5(it))) }
         return report
     }
 

File src/main/groovy/com/atlassian/maven/plugins/DependencyReportLine.groovy

 package com.atlassian.maven.plugins
 
-import org.apache.commons.lang.builder.EqualsBuilder
 import org.apache.maven.artifact.Artifact
 import org.apache.maven.plugin.MojoFailureException
-import org.apache.commons.lang.builder.HashCodeBuilder
 
 public class DependencyReportLine implements Comparable
 {
     String artifactId
     String version
     String md5
+    List<String> usedBy
 
     String toString()
     {
-        "$groupId:$artifactId:$version|$md5"
+        "$groupId:$artifactId:$version|${usedBy.join(',')}|$md5"
     }
 
     public int compareTo(Object line)
         int a = artifactId.compareTo(line.artifactId)
         if (a) return a
         int v = version.compareTo(line.version)
-        if (v) return v
-        int m = md5.compareTo(line.md5)
-        return m
+        return v
     }
 
     public boolean equals(Object obj)
     {
-        if (!obj) return false
-        if (obj == this) return true
-        if (obj.class != this.class) return false
-
-        new EqualsBuilder()
-                .append(groupId, obj.groupId)
-                .append(artifactId, obj.artifactId)
-                .append(version, obj.version)
-                .append(md5, obj.md5)
-                .isEquals()
+        toString().equals(obj.toString())
     }
 
     public int hashCode()
     {
-        new HashCodeBuilder()
-            .append(groupId)
-            .append(artifactId)
-            .append(version)
-            .append(md5)
-            .toHashCode()
+        toString().hashCode()
     }
 
-
-
-
     static DependencyReportLine from(Artifact artifact, String md5)
     {
         new DependencyReportLine(
                 groupId: artifact.groupId,
                 artifactId: artifact.artifactId,
                 version: artifact.version,
-                md5: artifact.snapshot ? 'SNAPSHOT' : md5)
+                md5: artifact.snapshot ? 'SNAPSHOT' : md5,
+                usedBy: artifact.dependencyTrail[1..artifact.dependencyTrail.size() - 2])
     }
 
     static DependencyReportLine from(String line)
         {
             throw new MojoFailureException("Could not parse artifact '${lineMatcher[0]}'")
         }
-
         new DependencyReportLine(
                 groupId: artifactMatcher[0],
                 artifactId: artifactMatcher[1],
                 version: artifactMatcher[2],
-                md5: lineMatcher[1])
+                md5: lineMatcher[2],
+                usedBy: lineMatcher[1].tokenize(','))
     }
 }

File src/main/groovy/com/atlassian/maven/plugins/ValidateDepdendenciesMojo.groovy

      */
     boolean skip = false
 
-
     void execute()
     {
         if (skip)