[MJAVADOC-304] added failOnError support when plugin run as a report

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1098423 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 201320a..96bc30b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -371,21 +371,22 @@
               <projectsDirectory>src/it</projectsDirectory>
               <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
               <pomIncludes>
-                <pomInclude>**/MJAVADOC-110/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-126/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-137/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-172/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-180/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-194/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-206/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-226/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-97/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-110/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-126/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-137/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-172/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-180/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-194/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-206/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-226/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-97/pom.xml</pomInclude>
                 <!-- pomInclude>**/MJAVADOC-181/pom.xml</pomInclude--><!-- seems to be wrong, see comment in Jira issue  -->
-                <pomInclude>**/MJAVADOC-257/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-259/pom.xml</pomInclude>
-                <pomInclude>**/MJAVADOC-262/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-257/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-259/pom.xml</pomInclude>
+                <pomInclude>MJAVADOC-262/pom.xml</pomInclude>
                 <pomInclude>MJAVADOC-275/pom.xml</pomInclude>
                 <pomInclude>MJAVADOC-280-*/pom.xml</pomInclude>
+                <pomInclude>site-failOnError/pom.xml</pomInclude>
               </pomIncludes>
               <postBuildHookScript>verify</postBuildHookScript>
               <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
diff --git a/src/it/site-failOnError/goals.txt b/src/it/site-failOnError/goals.txt
new file mode 100644
index 0000000..dd02b60
--- /dev/null
+++ b/src/it/site-failOnError/goals.txt
@@ -0,0 +1 @@
+clean site
\ No newline at end of file
diff --git a/src/it/site-failOnError/pom.xml b/src/it/site-failOnError/pom.xml
new file mode 100644
index 0000000..8a88942
--- /dev/null
+++ b/src/it/site-failOnError/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>MJAVADOC-304</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>MJAVADOC-304: failOnError=false in site</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>@sitePluginVersion@</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@pom.version@</version>
+          <configuration>
+            <failOnError>false</failOnError>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <failOnError>false</failOnError>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>javadoc</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/src/it/site-failOnError/src/main/java/App.java b/src/it/site-failOnError/src/main/java/App.java
new file mode 100644
index 0000000..47b0280
--- /dev/null
+++ b/src/it/site-failOnError/src/main/java/App.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ */
+class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
index 8f4fa90..8def205 100644
--- a/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
@@ -454,7 +454,7 @@
     protected boolean skip;
 
     /**
-     * Specifies whether the build will continue even if there are errors.
+     * Specifies if the build will fail if there are errors during javadoc execution or not.
      *
      * @parameter expression="${maven.javadoc.failOnError}" default-value="true"
      * @since 2.5
@@ -5774,9 +5774,9 @@
             {
                 throw (RuntimeException) e;
             }
-            throw new MojoExecutionException( prefix + e.getMessage(), e );
+            throw new MojoExecutionException( prefix + ": " + e.getMessage(), e );
         }
 
-        getLog().error( prefix + e.getMessage(), e );
+        getLog().error( prefix + ": " + e.getMessage(), e );
     }
 }
diff --git a/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java b/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
index b12be28..81acdbb 100644
--- a/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
+++ b/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
@@ -196,19 +196,19 @@
         }
         catch ( ArchiverException e )
         {
-            failOnError( "ArchiverException: Error while creating archive: ", e );
+            failOnError( "ArchiverException: Error while creating archive", e );
         }
         catch ( IOException e )
         {
-            failOnError( "IOException: Error while creating archive: ", e );
+            failOnError( "IOException: Error while creating archive", e );
         }
         catch ( MavenReportException e )
         {
-            failOnError( "MavenReportException: Error while creating archive: ", e );
+            failOnError( "MavenReportException: Error while creating archive", e );
         }
         catch ( RuntimeException e )
         {
-            failOnError( "RuntimeException: Error while creating archive: ", e );
+            failOnError( "RuntimeException: Error while creating archive", e );
         }
     }
 
diff --git a/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java b/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java
index 870cb52..7b52cb9 100644
--- a/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java
+++ b/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java
@@ -121,7 +121,26 @@
     {
         outputDirectory = getReportOutputDirectory();
 
-        executeReport( locale );
+        try
+        {
+            executeReport( locale );
+        }
+        catch ( MavenReportException e )
+        {
+            if ( failOnError )
+            {
+                throw e;
+            }
+            getLog().error( "Error while creating javadoc report: " + e.getMessage(), e );
+        }
+        catch ( RuntimeException e )
+        {
+            if ( failOnError )
+            {
+                throw e;
+            }
+            getLog().error( "Error while creating javadoc report: " + e.getMessage(), e );
+        }
     }
 
     /** {@inheritDoc} */
@@ -293,11 +312,11 @@
         }
         catch ( MavenReportException e )
         {
-            failOnError( "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation:", e );
+            failOnError( "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation", e );
         }
         catch ( RuntimeException e )
         {
-            failOnError( "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation:", e );
+            failOnError( "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation", e );
         }
     }