You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by fg...@apache.org on 2006/08/15 18:07:00 UTC

svn commit: r431630 - /maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java

Author: fgiust
Date: Tue Aug 15 09:07:00 2006
New Revision: 431630

URL: http://svn.apache.org/viewvc?rev=431630&view=rev
Log:
New section with licenses summary (project listing grouped by license name)

Modified:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java?rev=431630&r1=431629&r2=431630&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java Tue Aug 15 09:07:00 2006
@@ -123,6 +123,11 @@
     private boolean dependencyLocationsEnabled;
     
     private PlexusContainer container;
+    
+    /**
+     * Will be filled with license name / list of projects.
+     */
+    private Map licenseMap = new HashMap();
 
     /**
      * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
@@ -369,6 +374,9 @@
             // === Section: Project Dependency Graph.
             renderSectionProjectDependencyGraph();
 
+            // === Section: Licenses
+            renderSectionDependencyLicenseListing();
+
             if ( dependencyDetailsEnabled )
             {
                 // === Section: Dependency File Details.
@@ -454,7 +462,7 @@
             
             // === Section: Dependency Listings
             renderSectionDependencyListing();
-            
+
             endSection();
         }
 
@@ -869,6 +877,13 @@
             printDescriptionsAndURLs( listener.getRootNode() );
             endSection();
         }
+        
+        private void renderSectionDependencyLicenseListing()
+        {
+            startSection( getReportString( "report.dependencies.graph.tables.licenses" ) );
+            printGroupedLicenses();
+            endSection();
+        }
 
         private void renderDependenciesForScope( String scope, List artifacts, String[] tableHeader )
         {
@@ -957,6 +972,8 @@
         {
             Artifact artifact = node.getArtifact();
             String id = artifact.getDependencyConflictId();
+            
+            String unknownLicenseMessage = getReportString( "report.dependencies.graph.tables.unknown" );
 
             if ( !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
             {
@@ -1013,11 +1030,28 @@
                             {
                                 sink.link_();
                             }
+
+                            List projectsWithSameLicense = (List) licenseMap.get( licenseName );
+                            if ( projectsWithSameLicense == null )
+                            {
+                                projectsWithSameLicense = new ArrayList();
+                                licenseMap.put( licenseName, projectsWithSameLicense );
+                            }
+                            projectsWithSameLicense.add( artifactName );
+
                         }
                     }
                     else
                     {
                         sink.text( getReportString( "report.license.nolicense" ) );
+
+                        List projectsWithSameLicense = (List) licenseMap.get( unknownLicenseMessage );
+                        if ( projectsWithSameLicense == null )
+                        {
+                            projectsWithSameLicense = new ArrayList();
+                            licenseMap.put( unknownLicenseMessage, projectsWithSameLicense );
+                        }
+                        projectsWithSameLicense.add( artifactName );
                     }
                     sink.paragraph_();
 
@@ -1047,6 +1081,35 @@
 
                 sink.paragraph();
                 sink.text( artifact.getFile().toString() );
+                sink.paragraph_();
+            }
+        }
+        
+        private void printGroupedLicenses()
+        {
+            for ( Iterator iter = licenseMap.keySet().iterator(); iter.hasNext(); )
+            {
+                String licenseName = (String) iter.next();
+                sink.paragraph();
+                sink.bold();
+                sink.text( licenseName );
+                sink.text( ": " );
+                sink.bold_();
+
+                List projects = (List) licenseMap.get( licenseName );
+                Collections.sort( projects );
+
+                for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
+                {
+                    String projectName = (String) iterator.next();
+                    sink.text( projectName );
+                    if ( iterator.hasNext() )
+                    {
+                        sink.text( "," );
+                    }
+                    sink.text( " " );
+                }
+
                 sink.paragraph_();
             }
         }