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 2011/01/02 18:12:07 UTC

svn commit: r1054433 - /maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java

Author: hboutemy
Date: Sun Jan  2 17:12:07 2011
New Revision: 1054433

URL: http://svn.apache.org/viewvc?rev=1054433&view=rev
Log:
extracted a utility method

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=1054433&r1=1054432&r2=1054433&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java Sun Jan  2 17:12:07 2011
@@ -1608,7 +1608,7 @@ public abstract class AbstractJavadocMoj
     private boolean includeTransitiveDependencySources;
     
     /**
-     * List of included dependency-source patterns. Example: org.apache.maven:*
+     * List of included dependency-source patterns. Example: <code>org.apache.maven:*</code>
      *
      * 
      * @parameter
@@ -1618,7 +1618,7 @@ public abstract class AbstractJavadocMoj
     private List<String> dependencySourceIncludes;
 
     /**
-     * List of excluded dependency-source patterns. Example: org.apache.maven.shared:*
+     * List of excluded dependency-source patterns. Example: <code>org.apache.maven.shared:*</code>
      *
      * 
      * @parameter
@@ -2491,8 +2491,7 @@ public abstract class AbstractJavadocMoj
 
             if ( compileArtifactMap.get( newArtifact.getDependencyConflictId() ) != null )
             {
-                Artifact oldArtifact =
-                    (Artifact) compileArtifactMap.get( newArtifact.getDependencyConflictId() );
+                Artifact oldArtifact = compileArtifactMap.get( newArtifact.getDependencyConflictId() );
 
                 ArtifactVersion oldVersion = new DefaultArtifactVersion( oldArtifact.getVersion() );
                 ArtifactVersion newVersion = new DefaultArtifactVersion( newArtifact.getVersion() );
@@ -5100,14 +5099,7 @@ public abstract class AbstractJavadocMoj
                 }
                 catch ( Exception e )
                 {
-                    if ( getLog().isDebugEnabled() )
-                    {
-                        getLog().error( "Unable to retrieve the dependency: " + dependency + ". Ignored.", e );
-                    }
-                    else
-                    {
-                        getLog().error( "Unable to retrieve the dependency: " + dependency + ". Ignored." );
-                    }
+                    logError( "Unable to retrieve the dependency: " + dependency + ". Ignored.", e );
                 }
 
                 if ( artifact != null && artifact.getFile().exists() )
@@ -5127,14 +5119,7 @@ public abstract class AbstractJavadocMoj
                 }
                 catch ( IOException e )
                 {
-                    if ( getLog().isDebugEnabled() )
-                    {
-                        getLog().error( "IOException: " + e.getMessage(), e );
-                    }
-                    else
-                    {
-                        getLog().error( "IOException: " + e.getMessage() );
-                    }
+                    logError( "IOException: " + e.getMessage(), e );
                 }
             }
         }
@@ -5240,7 +5225,7 @@ public abstract class AbstractJavadocMoj
     private List<OfflineLink> getModulesLinks()
         throws MavenReportException
     {
-        if ( !( detectOfflineLinks && !isAggregator() && reactorProjects != null ) )
+        if ( !detectOfflineLinks || isAggregator() || reactorProjects == null )
         {
             return Collections.emptyList();
         }
@@ -5279,14 +5264,7 @@ public abstract class AbstractJavadocMoj
                 }
                 catch ( MavenInvocationException e )
                 {
-                    if ( getLog().isDebugEnabled() )
-                    {
-                        getLog().error( "MavenInvocationException: " + e.getMessage(), e );
-                    }
-                    else
-                    {
-                        getLog().error( "MavenInvocationException: " + e.getMessage() );
-                    }
+                    logError( "MavenInvocationException: " + e.getMessage(), e );
 
                     String invokerLogContent = JavadocUtil.readFile( invokerLogFile, "UTF-8" );
                     
@@ -5378,12 +5356,8 @@ public abstract class AbstractJavadocMoj
                         getLog().debug(
                                        "Error when building the artifact: " + artifact.toString()
                                            + ". Ignored to add Javadoc link." );
-                        getLog().error( "ProjectBuildingException: " + e.getMessage(), e );
-                    }
-                    else
-                    {
-                        getLog().error( "ProjectBuildingException: " + e.getMessage() );
                     }
+                    logError( "ProjectBuildingException: " + e.getMessage(), e );
                 }
             }
         }
@@ -5553,14 +5527,7 @@ public abstract class AbstractJavadocMoj
         }
         catch ( IOException e )
         {
-            if ( getLog().isDebugEnabled() )
-            {
-                getLog().error( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
-            }
-            else
-            {
-                getLog().error( "Unable to write '" + commandLineFile.getName() + "' debug script file" );
-            }
+            logError( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
         }
     }
 
@@ -5752,5 +5719,23 @@ public abstract class AbstractJavadocMoj
     {
         return JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER;
     }
-    
+
+    /**
+     * Logs an error with throwable content only if in debug.
+     * 
+     * @param message
+     * @param t
+     */
+    protected void logError( String message, Throwable t )
+    {
+        if ( getLog().isDebugEnabled() )
+        {
+            getLog().error( message, t );
+        }
+        else
+        {
+            getLog().error( message );
+        }
+    }
+
 }