You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2016/06/06 20:48:57 UTC
svn commit: r1747075 - in /maven/plugins/trunk/maven-javadoc-plugin: pom.xml
src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java
Author: rfscholte
Date: Mon Jun 6 20:48:57 2016
New Revision: 1747075
URL: http://svn.apache.org/viewvc?rev=1747075&view=rev
Log:
[MJAVADOC-432] Downgrade "Error fetching link: .../package-list"
Patch contributed by Kaz Nishimura. Reviewed, accepted and extended with junittest by Robert Scholte
Added:
maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java
Modified:
maven/plugins/trunk/maven-javadoc-plugin/pom.xml
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=1747075&r1=1747074&r2=1747075&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Mon Jun 6 20:48:57 2016
@@ -89,6 +89,9 @@ under the License.
<contributor>
<name>Richard Eckart de Castilho</name>
</contributor>
+ <contributor>
+ <name>Kaz Nishimura</name>
+ </contributor>
</contributors>
<dependencies>
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=1747075&r1=1747074&r2=1747075&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 Mon Jun 6 20:48:57 2016
@@ -4004,7 +4004,7 @@ public abstract class AbstractJavadocMoj
{
continue;
}
- if ( isValidJavadocLink( location ) )
+ if ( isValidJavadocLink( location, false ) )
{
addArgIfNotEmpty( arguments, "-linkoffline",
JavadocUtil.quotedPathArgument( url ) + " " + JavadocUtil.quotedPathArgument(
@@ -5592,7 +5592,7 @@ public abstract class AbstractJavadocMoj
{
String url = getJavadocLink( artifactProject );
- if ( isValidJavadocLink( url ) )
+ if ( isValidJavadocLink( url, true ) )
{
getLog().debug( "Added Javadoc link: " + url + " for " + artifactProject.getId() );
@@ -5731,12 +5731,14 @@ public abstract class AbstractJavadocMoj
/**
* @param link not null
+ * @param detecting <code>true</code> if the link is generated by
+ * <code>detectLinks</code>, or <code>false</code> otherwise
* @return <code>true</code> if the link has a <code>/package-list</code>, <code>false</code> otherwise.
* @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#package-list">
* package-list spec</a>
* @since 2.6
*/
- private boolean isValidJavadocLink( String link )
+ protected boolean isValidJavadocLink( String link, boolean detecting )
{
try
{
@@ -5757,7 +5759,14 @@ public abstract class AbstractJavadocMoj
}
if ( !dir.isDirectory() )
{
- getLog().error( "The given File link: " + dir + " is not a dir." );
+ if ( detecting )
+ {
+ getLog().warn( "The given File link: " + dir + " is not a dir." );
+ }
+ else
+ {
+ getLog().error( "The given File link: " + dir + " is not a dir." );
+ }
}
linkUri = new File( dir, "package-list" ).toURI();
}
@@ -5766,7 +5775,14 @@ public abstract class AbstractJavadocMoj
{
if ( getLog().isErrorEnabled() )
{
- getLog().error( "Invalid link: " + link + "/package-list. Ignored it." );
+ if ( detecting )
+ {
+ getLog().warn( "Invalid link: " + link + "/package-list. Ignored it." );
+ }
+ else
+ {
+ getLog().error( "Invalid link: " + link + "/package-list. Ignored it." );
+ }
}
return false;
@@ -5778,7 +5794,14 @@ public abstract class AbstractJavadocMoj
{
if ( getLog().isErrorEnabled() )
{
- getLog().error( "Malformed link: " + link + "/package-list. Ignored it." );
+ if ( detecting )
+ {
+ getLog().warn( "Malformed link: " + link + "/package-list. Ignored it." );
+ }
+ else
+ {
+ getLog().error( "Malformed link: " + link + "/package-list. Ignored it." );
+ }
}
return false;
}
@@ -5786,7 +5809,14 @@ public abstract class AbstractJavadocMoj
{
if ( getLog().isErrorEnabled() )
{
- getLog().error( "Error fetching link: " + link + "/package-list. Ignored it." );
+ if ( detecting )
+ {
+ getLog().warn( "Error fetching link: " + link + "/package-list. Ignored it." );
+ }
+ else
+ {
+ getLog().error( "Error fetching link: " + link + "/package-list. Ignored it." );
+ }
}
return false;
}
Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java?rev=1747075&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojoTest.java Mon Jun 6 20:48:57 2016
@@ -0,0 +1,78 @@
+package org.apache.maven.plugin.javadoc;
+
+/*
+ * 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 static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+
+import junit.framework.TestCase;
+
+public class AbstractJavadocMojoTest
+ extends TestCase
+{
+ AbstractJavadocMojo mojo;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ mojo = new AbstractJavadocMojo()
+ {
+ @Override
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ }
+ };
+ }
+
+ public void testMJAVADOC432_DetectLinksMessages()
+ {
+ Log log = mock( Log.class );
+ when( log.isErrorEnabled() ).thenReturn( true );
+ mojo.setLog( log );
+ mojo.outputDirectory = new File( "target/test-classes" );
+
+ // first continues after warning, next exits with warning
+ assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).getPath(), true ) );
+ assertFalse( mojo.isValidJavadocLink( "file://%%", true ) );
+ assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).toURI().toString(), true ) );
+ verify( log, times( 4 ) ).warn( anyString() );
+ verify( log, never() ).error( anyString() );
+
+ // first continues after error, next exits with error
+ assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).getPath(), false ) );
+ assertFalse( mojo.isValidJavadocLink( "file://%%", false ) );
+ assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).toURI().toString(), false ) );
+ verify( log, times( 4 ) ).error( anyString() );
+ verify( log, times( 4 ) ).warn( anyString() ); // no extra warnings
+ }
+}