Commits

Samuel Le Berrigaud committed abd3cd0

- Added dependency trail to report.

Comments (0)

Files changed (3)

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
     }
 

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(','))
     }
 }

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

      */
     boolean skip = false
 
-
     void execute()
     {
         if (skip)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.