You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2015/03/29 15:04:22 UTC

svn commit: r1669907 - in /maven/plugins/trunk/maven-javadoc-plugin/src: main/java/org/apache/maven/plugin/javadoc/ test/java/org/apache/maven/plugin/javadoc/ test/java/org/apache/maven/plugin/javadoc/stubs/ test/resources/unit/javadocjar-failonerror/ ...

Author: khmarbaise
Date: Sun Mar 29 13:04:22 2015
New Revision: 1669907

URL: http://svn.apache.org/r1669907
Log:
[MJAVADOC-347] javadoc:aggregate-jar doesn't create Javadoc JAR if failOnError=false and there is an error
 Applied patch of Luis Miranda with slight modifications.

Added:
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarFailOnErrorMavenProjectStub.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/App.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/package.html
Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocJarTest.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java?rev=1669907&r1=1669906&r2=1669907&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java Sun Mar 29 13:04:22 2015
@@ -186,8 +186,19 @@ public class JavadocJar
         try
         {
             executeReport( Locale.getDefault() );
+        }
+        catch ( MavenReportException e )
+        {
+            failOnError( "MavenReportException: Error while generating Javadoc", e );
+        }
+        catch ( RuntimeException e )
+        {
+            failOnError( "RuntimeException: Error while generating Javadoc", e );
+        }
 
-            if ( innerDestDir.exists() )
+        if ( innerDestDir.exists() )
+        {
+            try
             {
                 File outputFile = generateArchive( innerDestDir, finalName + "-" + getClassifier() + ".jar" );
 
@@ -202,22 +213,18 @@ public class JavadocJar
                     projectHelper.attachArtifact( project, "javadoc", getClassifier(), outputFile );
                 }
             }
-        }
-        catch ( ArchiverException e )
-        {
-            failOnError( "ArchiverException: Error while creating archive", e );
-        }
-        catch ( IOException e )
-        {
-            failOnError( "IOException: Error while creating archive", e );
-        }
-        catch ( MavenReportException e )
-        {
-            failOnError( "MavenReportException: Error while creating archive", e );
-        }
-        catch ( RuntimeException e )
-        {
-            failOnError( "RuntimeException: Error while creating archive", e );
+            catch ( ArchiverException e )
+            {
+                failOnError( "ArchiverException: Error while creating archive", e );
+            }
+            catch ( IOException e )
+            {
+                failOnError( "IOException: Error while creating archive", e );
+            }
+            catch ( RuntimeException e )
+            {
+                failOnError( "RuntimeException: Error while creating archive", e );
+            }
         }
     }
 

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocJarTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocJarTest.java?rev=1669907&r1=1669906&r2=1669907&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocJarTest.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocJarTest.java Sun Mar 29 13:04:22 2015
@@ -121,4 +121,17 @@ public class JavadocJarTest
                                        "target/test/unit/javadocjar-invalid-destdir/target/javadocjar-invalid-destdir-javadoc.jar" );
         assertTrue( !FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
     }
+
+    public void testContinueIfFailOnErrorIsFalse() throws Exception
+    {
+        File testPom =
+                new File( getBasedir(), "src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml" );
+        JavadocJar mojo = (JavadocJar) lookupMojo( "jar", testPom );
+        mojo.execute();
+
+        //check if the javadoc jar file was generated
+        File generatedFile =
+                new File( getBasedir(), "target/test/unit/javadocjar-failonerror/target/javadocjar-failonerror-javadoc.jar" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+    }
 }

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarFailOnErrorMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarFailOnErrorMavenProjectStub.java?rev=1669907&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarFailOnErrorMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/JavadocJarFailOnErrorMavenProjectStub.java Sun Mar 29 13:04:22 2015
@@ -0,0 +1,88 @@
+package org.apache.maven.plugin.javadoc.stubs;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Scm;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id$
+ */
+public class JavadocJarFailOnErrorMavenProjectStub
+    extends MavenProjectStub
+{
+    private Scm scm;
+
+    public JavadocJarFailOnErrorMavenProjectStub()
+    {
+        readModel( new File( getBasedir(), "javadocjar-failonerror-plugin-config.xml" ) );
+
+        setGroupId( getModel().getGroupId() );
+        setArtifactId( getModel().getArtifactId() );
+        setVersion( getModel().getVersion() );
+        setName( getModel().getName() );
+        setUrl( getModel().getUrl() );
+        setPackaging( getModel().getPackaging() );
+
+        Scm scm = new Scm();
+        scm.setConnection( "scm:svn:http://svn.apache.org/maven/sample/trunk" );
+        setScm( scm );
+
+        JavadocPluginArtifactStub artifact =
+            new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
+        artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
+        artifact.setType( "jar" );
+        artifact.setBaseVersion( "1.0-SNAPSHOT" );
+        setArtifact( artifact );
+
+        Build build = new Build();
+        build.setFinalName( "javadocjar-failonerror" );
+        build.setDirectory( super.getBasedir() + "/target/test/unit/javadocjar-failonerror/target" );
+        setBuild( build );
+
+        List<String> compileSourceRoots = new ArrayList<String>();
+        compileSourceRoots.add( getBasedir() + "/javadocjar/def" );
+        setCompileSourceRoots( compileSourceRoots );
+    }
+
+    /** {@inheritDoc} */
+    public Scm getScm()
+    {
+        return scm;
+    }
+
+    /** {@inheritDoc} */
+    public void setScm( Scm scm )
+    {
+        this.scm = scm;
+    }
+
+    /** {@inheritDoc} */
+    public File getBasedir()
+    {
+        return new File( super.getBasedir() + "/src/test/resources/unit/javadocjar-failonerror" );
+    }
+}

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml?rev=1669907&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml Sun Mar 29 13:04:22 2015
@@ -0,0 +1,79 @@
+<!--
+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.unit</groupId>
+  <artifactId>javadocjar-failonerror</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2006</inceptionYear>
+  <name>Maven Javadoc Plugin Javadoc Jar Default Config Test</name>
+  <url>http://maven.apache.org</url>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <project implementation="org.apache.maven.plugin.javadoc.stubs.JavadocJarFailOnErrorMavenProjectStub"/>
+          <localRepository>${localRepository}</localRepository>
+          <jarOutputDirectory>${basedir}/target/test/unit/javadocjar-failonerror/target</jarOutputDirectory>
+          <outputDirectory>${basedir}/target/test/unit/javadocjar-failonerror/target/site/apidocs</outputDirectory>
+          <finalName>javadocjar-failonerror</finalName>
+          <attach>true</attach>
+          <classifier>javadoc</classifier>
+          <breakiterator>false</breakiterator>
+          <old>false</old>
+          <show>protected</show>
+          <quiet>true</quiet>
+          <verbose>false</verbose>
+          <author>true</author>
+          <encoding>ISO-8859-1</encoding>
+          <docfilessubdirs>false</docfilessubdirs>
+          <linksource>false</linksource>
+          <nocomment>false</nocomment>
+          <nodeprecated>false</nodeprecated>
+          <nodeprecatedlist>false</nodeprecatedlist>
+          <nohelp>false</nohelp>
+          <noindex>false</noindex>
+          <nonavbar>false</nonavbar>
+          <nosince>false</nosince>
+          <notree>false</notree>
+          <serialwarn>false</serialwarn>
+          <splitindex>false</splitindex>
+          <stylesheet>java</stylesheet>
+          <!--commas in following elements are to test MJAVADOC-93-->
+          <doctitle>doc,title</doctitle>
+          <bottom>bottom,comma test</bottom>
+          <footer>my footer, and something</footer>
+          <header>my header, and something else</header>
+          <windowtitle>Maven Javadoc Plugin, Javadoc Jar Default Config Test 1.0-SNAPSHOT API</windowtitle>
+          <groups/>
+          <tags/>
+          <use>true</use>
+          <version>true</version>
+          <debug>true</debug>
+          <failOnError>false</failOnError>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/App.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/App.java?rev=1669907&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/App.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/App.java Sun Mar 29 13:04:22 2015
@@ -0,0 +1,50 @@
+package javadocjar.def;
+
+/*
+ * 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.
+ */
+
+/**
+ * This is a sample app class with javadoc
+ *
+ * @author Maria Odea Ching
+ */
+public class App
+{
+
+    /**
+     * The main method
+     *
+     * @param args  an array of strings that contains the arguments
+     */
+    public static void main( String[] args )
+    {
+        System.out.println( "Sample Application." );
+    }
+
+    /**
+     * Sample method
+     *
+     * @param str   the string to be displayed
+     */
+    protected void sampleMethod( String str )
+    {
+        System.out.println( str );
+    }
+
+}
\ No newline at end of file

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/package.html
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/package.html?rev=1669907&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/package.html (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/javadocjar-failonerror/javadocjar/def/package.html Sun Mar 29 13:04:22 2015
@@ -0,0 +1 @@
+This is an invalid package.html.