You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2008/07/19 19:56:06 UTC

svn commit: r678195 - /maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java

Author: hboutemy
Date: Sat Jul 19 10:56:06 2008
New Revision: 678195

URL: http://svn.apache.org/viewvc?rev=678195&view=rev
Log:
refactoring: extracted hasSealed method

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

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java?rev=678195&r1=678194&r2=678195&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java Sat Jul 19 10:56:06 2008
@@ -386,57 +386,7 @@
         TotalCell totaldebug = new TotalCell( DEFAULT_DECIMAL_FORMAT );
         TotalCell totalsealed = new TotalCell( DEFAULT_DECIMAL_FORMAT );
 
-        boolean hasSealed = false;
-        for ( Iterator it = alldeps.iterator(); it.hasNext(); )
-        {
-            Artifact artifact = (Artifact) it.next();
-
-            // TODO site:run Why do we need to resolve this...
-            if ( artifact.getFile() == null && !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
-            {
-                try
-                {
-                    repoUtils.resolve( artifact );
-                }
-                catch ( ArtifactResolutionException e )
-                {
-                    log.error( "Artifact: " + artifact.getId() + " has no file.", e );
-                    continue;
-                }
-                catch ( ArtifactNotFoundException e )
-                {
-                    if ( ( dependencies.getProject().getGroupId().equals( artifact.getGroupId() ) )
-                        && ( dependencies.getProject().getArtifactId().equals( artifact.getArtifactId() ) )
-                        && ( dependencies.getProject().getVersion().equals( artifact.getVersion() ) ) )
-                    {
-                        log.warn( "The artifact of this project has never been deployed." );
-                    }
-                    else
-                    {
-                        log.error( "Artifact: " + artifact.getId() + " has no file.", e );
-                    }
-
-                    continue;
-                }
-            }
-
-            if ( JAR_SUBTYPE.contains( artifact.getType().toLowerCase() ) )
-            {
-                try
-                {
-                    JarData jarDetails = dependencies.getJarDependencyDetails( artifact );
-                    if ( jarDetails.isSealed() )
-                    {
-                        hasSealed = true;
-                        break;
-                    }
-                }
-                catch ( IOException e )
-                {
-                    log.error( "IOException: " + e.getMessage(), e );
-                }
-            }
-        }
+        boolean hasSealed = hasSealed( alldeps );
 
         // Table header
 
@@ -1268,6 +1218,64 @@
     }
 
     /**
+     * @param artifacts not null
+     * @return <code>true</code> if one artifact in the list is sealed, <code>false</code> otherwise.
+     */
+    private boolean hasSealed( List artifacts )
+    {
+        for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+        {
+            Artifact artifact = (Artifact) it.next();
+
+            // TODO site:run Why do we need to resolve this...
+            if ( artifact.getFile() == null && !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
+            {
+                try
+                {
+                    repoUtils.resolve( artifact );
+                }
+                catch ( ArtifactResolutionException e )
+                {
+                    log.error( "Artifact: " + artifact.getId() + " has no file.", e );
+                    continue;
+                }
+                catch ( ArtifactNotFoundException e )
+                {
+                    if ( ( dependencies.getProject().getGroupId().equals( artifact.getGroupId() ) )
+                        && ( dependencies.getProject().getArtifactId().equals( artifact.getArtifactId() ) )
+                        && ( dependencies.getProject().getVersion().equals( artifact.getVersion() ) ) )
+                    {
+                        log.warn( "The artifact of this project has never been deployed." );
+                    }
+                    else
+                    {
+                        log.error( "Artifact: " + artifact.getId() + " has no file.", e );
+                    }
+
+                    continue;
+                }
+            }
+
+            if ( JAR_SUBTYPE.contains( artifact.getType().toLowerCase() ) )
+            {
+                try
+                {
+                    JarData jarDetails = dependencies.getJarDependencyDetails( artifact );
+                    if ( jarDetails.isSealed() )
+                    {
+                        return true;
+                    }
+                }
+                catch ( IOException e )
+                {
+                    log.error( "IOException: " + e.getMessage(), e );
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
      * @return an HTML script tag with the Javascript used by the dependencies report.
      */
     private static String getJavascript()