maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r676627 - in /maven/plugins/trunk/maven-project-info-reports-plugin/src/main: java/org/apache/maven/report/projectinfo/dependencies/ java/org/apache/maven/report/projectinfo/dependencies/renderer/ resources/
Date Mon, 14 Jul 2008 15:42:29 GMT
Author: vsiveton
Date: Mon Jul 14 08:42:28 2008
New Revision: 676627

URL: http://svn.apache.org/viewvc?rev=676627&view=rev
Log:
o take care if the repo is blacklisted or not
o ping repo url before calling wagon to prevent TransferFailedException
o display stacktrace for error logs in dependencyExistsInRepo() only if log is in debug mode
o added a new Blacklisted column in Dependency Repository Locations table

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

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java?rev=676627&r1=676626&r2=676627&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
Mon Jul 14 08:42:28 2008
@@ -160,10 +160,20 @@
     /**
      * @param repo not null
      * @param artifact not null
-     * @return <code>true</code> if the artifact exists in the given repo, <code>false</ccode>
otherwise
+     * @return <code>true</code> if the artifact exists in the given repo, <code>false</code>
otherwise or if
+     * the repo is blacklisted.
      */
     public boolean dependencyExistsInRepo( ArtifactRepository repo, Artifact artifact )
     {
+        if ( repo.isBlacklisted() )
+        {
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "The repo '" + repo.getId() + "' is black listed - Ignored it"
);
+            }
+            return false;
+        }
+
         Wagon wagon;
         try
         {
@@ -205,22 +215,50 @@
         }
         catch ( ConnectionException e )
         {
-            log.error( "Unable to connect to: " + repo.getUrl(), e );
+            if ( log.isDebugEnabled() )
+            {
+                log.error( "Unable to connect to: " + repo.getUrl(), e );
+            }
+            else
+            {
+                log.error( "Unable to connect to: " + repo.getUrl() );
+            }
             return false;
         }
         catch ( AuthenticationException e )
         {
-            log.error( "Unable to connect to: " + repo.getUrl(), e );
+            if ( log.isDebugEnabled() )
+            {
+                log.error( "Unable to connect to: " + repo.getUrl(), e );
+            }
+            else
+            {
+                log.error( "Unable to connect to: " + repo.getUrl() );
+            }
             return false;
         }
         catch ( TransferFailedException e )
         {
-            log.error( "Unable to determine if resource " + artifact + " exists in " + repo.getUrl(),
e );
+            if ( log.isDebugEnabled() )
+            {
+                log.error( "Unable to determine if resource " + artifact + " exists in "
+ repo.getUrl(), e );
+            }
+            else
+            {
+                log.error( "Unable to determine if resource " + artifact + " exists in "
+ repo.getUrl() );
+            }
             return false;
         }
         catch ( AuthorizationException e )
         {
-            log.error( "Unable to connect to: " + repo.getUrl(), e );
+            if ( log.isDebugEnabled() )
+            {
+                log.error( "Unable to connect to: " + repo.getUrl(), e );
+            }
+            else
+            {
+                log.error( "Unable to connect to: " + repo.getUrl() );
+            }
             return false;
         }
         catch ( AbstractMethodError e )
@@ -236,7 +274,14 @@
             }
             catch ( ConnectionException e )
             {
-                log.error( "Error disconnecting wagon - ignored", e );
+                if ( log.isDebugEnabled() )
+                {
+                    log.error( "Error disconnecting wagon - ignored", e );
+                }
+                else
+                {
+                    log.error( "Error disconnecting wagon - ignored" );
+                }
             }
         }
     }

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=676627&r1=676626&r2=676627&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
Mon Jul 14 08:42:28 2008
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.text.DecimalFormat;
@@ -55,7 +56,6 @@
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 import org.apache.maven.shared.dependency.tree.DependencyNode;
 import org.apache.maven.shared.jar.JarData;
-import org.apache.maven.wagon.Wagon;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -582,10 +582,55 @@
         while ( it.hasNext() )
         {
             ArtifactRepository repo = (ArtifactRepository) it.next();
+
             repos.put( repo.getId(), repo );
         }
     }
 
+    private void blacklistRepositoryMap( Map repos, List repoUrlBlackListed )
+    {
+        for ( Iterator it = repos.keySet().iterator(); it.hasNext(); )
+        {
+            String key = (String) it.next();
+            ArtifactRepository repo = (ArtifactRepository) repos.get( key );
+
+            // ping repo
+            if ( !repo.isBlacklisted() )
+            {
+                if ( !repoUrlBlackListed.contains( repo.getUrl() ) )
+                {
+                    try
+                    {
+                        URL repoUrl = new URL( repo.getUrl() );
+                        if ( repoUrl.openStream() == null )
+                        {
+                            log.warn( "The repository url '" + repoUrl + "' has no stream
- Repository '"
+                                + repo.getId() + "' will be blacklisted." );
+                            repo.setBlacklisted( true );
+                            repoUrlBlackListed.add( repo.getUrl() );
+                        }
+                    }
+                    catch ( Exception e )
+                    {
+                        log.warn( "The repository url '" + repo.getUrl() + "' is invalid
- Repository '" + repo.getId()
+                            + "' will be blacklisted." );
+                        repo.setBlacklisted( true );
+                        repoUrlBlackListed.add( repo.getUrl() );
+                    }
+                }
+                else
+                {
+                    repo.setBlacklisted( true );
+                }
+            }
+            else
+            {
+                repoUrlBlackListed.add( repo.getUrl() );
+            }
+        }
+    }
+
+
     private void renderSectionDependencyRepositoryLocations()
     {
         startSection( getReportString( "report.dependencies.repo.locations.title" ) );
@@ -598,14 +643,12 @@
         Map repoMap = new HashMap();
 
         populateRepositoryMap( repoMap, repoUtils.getRemoteArtifactRepositories() );
-
         for ( Iterator it = alldeps.iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
             try
             {
                 MavenProject artifactProject = repoUtils.getMavenProjectFromRepository( artifact
);
-
                 populateRepositoryMap( repoMap, artifactProject.getRemoteArtifactRepositories()
);
             }
             catch ( ProjectBuildingException e )
@@ -614,6 +657,9 @@
             }
         }
 
+        List repoUrlBlackListed = new ArrayList();
+        blacklistRepositoryMap( repoMap, repoUrlBlackListed );
+
         // Render Repository List
 
         startTable();
@@ -621,8 +667,17 @@
         String url = getReportString( "report.dependencies.repo.locations.column.url" );
         String release = getReportString( "report.dependencies.repo.locations.column.release"
);
         String snapshot = getReportString( "report.dependencies.repo.locations.column.snapshot"
);
+        String blacklisted = getReportString( "report.dependencies.repo.locations.column.blacklisted"
);
 
-        String[] tableHeader = new String[]{repoid, url, release, snapshot};
+        String[] tableHeader;
+        if ( repoUrlBlackListed.isEmpty() )
+        {
+            tableHeader = new String[] { repoid, url, release, snapshot };
+        }
+        else
+        {
+            tableHeader = new String[] { repoid, url, release, snapshot, blacklisted };
+        }
         tableHeader( tableHeader );
 
         String releaseEnabled = getReportString( "report.dependencies.repo.locations.cell.release.enabled"
);
@@ -631,6 +686,9 @@
         String snapshotEnabled = getReportString( "report.dependencies.repo.locations.cell.snapshot.enabled"
);
         String snapshotDisabled = getReportString( "report.dependencies.repo.locations.cell.snapshot.disabled"
);
 
+        String blacklistedEnabled = getReportString( "report.dependencies.repo.locations.cell.blacklisted.enabled"
);
+        String blacklistedDisabled = getReportString( "report.dependencies.repo.locations.cell.blacklisted.disabled"
);
+
         for ( Iterator it = repoMap.keySet().iterator(); it.hasNext(); )
         {
             String key = (String) it.next();
@@ -640,9 +698,16 @@
             tableCell( repo.getId() );
 
             sink.tableCell();
-            sink.link( repo.getUrl() );
-            sink.text( repo.getUrl() );
-            sink.link_();
+            if ( repo.isBlacklisted() )
+            {
+                sink.text( repo.getUrl() );
+            }
+            else
+            {
+                sink.link( repo.getUrl() );
+                sink.text( repo.getUrl() );
+                sink.link_();
+            }
             sink.tableCell_();
 
             ArtifactRepositoryPolicy releasePolicy = repo.getReleases();
@@ -650,6 +715,11 @@
 
             ArtifactRepositoryPolicy snapshotPolicy = repo.getSnapshots();
             tableCell( snapshotPolicy.isEnabled() ? snapshotEnabled : snapshotDisabled );
+
+            if ( !repoUrlBlackListed.isEmpty() )
+            {
+                tableCell( repo.isBlacklisted() ? blacklistedEnabled : blacklistedDisabled
);
+            }
             sink.tableRow_();
         }
 

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties?rev=676627&r1=676626&r2=676627&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report.properties
Mon Jul 14 08:42:28 2008
@@ -73,7 +73,10 @@
 report.dependencies.repo.locations.cell.release.enabled            = Yes
 report.dependencies.repo.locations.cell.snapshot.disabled          = -
 report.dependencies.repo.locations.cell.snapshot.enabled           = Yes
+report.dependencies.repo.locations.cell.blacklisted.disabled       = -
+report.dependencies.repo.locations.cell.blacklisted.enabled        = Yes
 report.dependencies.repo.locations.column.artifact                 = Artifact
+report.dependencies.repo.locations.column.blacklisted              = Blacklisted
 report.dependencies.repo.locations.column.release                  = Release
 report.dependencies.repo.locations.column.repoid                   = Repo ID
 report.dependencies.repo.locations.column.snapshot                 = Snapshot

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_fr.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_fr.properties?rev=676627&r1=676626&r2=676627&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_fr.properties
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_fr.properties
Mon Jul 14 08:42:28 2008
@@ -73,7 +73,10 @@
 report.dependencies.repo.locations.cell.release.enabled            = Oui
 report.dependencies.repo.locations.cell.snapshot.disabled          = -
 report.dependencies.repo.locations.cell.snapshot.enabled           = Oui
-report.dependencies.repo.locations.column.artifact                 = artefact
+report.dependencies.repo.locations.cell.blacklisted.disabled       = -
+report.dependencies.repo.locations.cell.blacklisted.enabled        = Oui
+report.dependencies.repo.locations.column.artifact                 = Artefact
+report.dependencies.repo.locations.column.blacklisted              = Blacklist\u00e9
 report.dependencies.repo.locations.column.release                  = D\u00e9gagement
 report.dependencies.repo.locations.column.repoid                   = R\u00e9f\u00e9rentiel
ID
 report.dependencies.repo.locations.column.snapshot                 = Snapshot



Mime
View raw message