Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
[MJAVADOC-387] Handle JDK8 -Xdoclint
Browse files Browse the repository at this point in the history
Add proper handling of -Xdoclint. Option is only evaluated if Java 1.8+ is used otherwise a warning is issued.
Due to a limitation in Modello, it cannot simply enabled by <doclint /> because it is umarshaled to null instead of "". One has to use <doclint>all</doclint> explicitly.

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1765097 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
michael-o committed Oct 15, 2016
1 parent f3f4b78 commit 599355d
Showing 1 changed file with 43 additions and 14 deletions.
Expand Up @@ -279,6 +279,15 @@ public abstract class AbstractJavadocMojo
*/
private static final float SINCE_JAVADOC_1_6 = 1.6f;

/**
* For Javadoc options appears since Java 8.0.
* See <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/index.html">
* Javadoc Technology</a>
*
* @since 3.0.0
*/
private static final float SINCE_JAVADOC_1_8 = 1.8f;

// ----------------------------------------------------------------------
// Mojo components
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -310,16 +319,16 @@ public abstract class AbstractJavadocMojo
*/
@Component
private ArtifactResolver resolver;

@Component
private ResourceResolver resourceResolver;

@Component
private org.apache.maven.shared.artifact.resolve.ArtifactResolver artifactResolver;

@Component
private ArtifactHandlerManager artifactHandlerManager;

@Component
private DependencyResolver dependencyResolver;

Expand Down Expand Up @@ -359,7 +368,7 @@ public abstract class AbstractJavadocMojo
*/
@Parameter( defaultValue = "${project}", readonly = true, required = true )
protected MavenProject project;

@Parameter( defaultValue = "${plugin}", readonly = true )
private PluginDescriptor plugin;

Expand Down Expand Up @@ -965,6 +974,16 @@ public abstract class AbstractJavadocMojo
@Parameter( property = "docfilessubdirs", defaultValue = "false" )
private boolean docfilessubdirs;

/**
* Specifies specific checks to be performed on Javadoc comments.
* <br/>
* See <a href="http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#BEJEFABE">doclint</a>.
*
* @since 3.0.0
*/
@Parameter( property = "doclint" )
private String doclint;

/**
* Specifies the title to be placed near the top of the overview summary file.
* <br/>
Expand Down Expand Up @@ -1826,6 +1845,14 @@ protected File getJavadocDirectory()
return javadocDirectory;
}

/**
* @return the doclint specific checks configuration
*/
protected String getDoclint()
{
return doclint;
}

/**
* @return the title to be placed near the top of the overview summary file
*/
Expand Down Expand Up @@ -1881,27 +1908,27 @@ public void execute()
verifyRemovedParameter( "aggregator" );
verifyRemovedParameter( "proxyHost" );
verifyRemovedParameter( "proxyPort" );

doExecute();
}

abstract void doExecute() throws MojoExecutionException, MojoFailureException;

private void verifyRemovedParameter( String paramName )
{
Object pluginConfiguration = plugin.getPlugin().getConfiguration();
if ( pluginConfiguration instanceof Xpp3Dom )
{
Xpp3Dom configDom = (Xpp3Dom) pluginConfiguration;

if ( configDom.getChild( paramName ) != null )
{
throw new IllegalArgumentException( "parameter '" + paramName
+ "' has been removed from the plugin, please verify documentation." );
}
}
}

/**
* The <a href="package-summary.html">package documentation</a> details the
* Javadoc Options used by this Plugin.
Expand Down Expand Up @@ -2046,7 +2073,7 @@ protected void executeReport( Locale unusedLocale )
// ----------------------------------------------------------------------

// MJAVADOC-365 if includes/excludes are specified, these take precedence over the default
// package-based mode and force javadoc into file-based mode unless subpackages are
// package-based mode and force javadoc into file-based mode unless subpackages are
// specified. Subpackages take precedence over file-based include/excludes. Why? Because
// getFiles(...) returns an empty list when subpackages are specified.
boolean includesExcludesActive =
Expand Down Expand Up @@ -2366,7 +2393,7 @@ private TransformableFilter createDependencyArtifactFilter()
*/
private SourceResolverConfig getDependencySourceResolverConfig()
{
return configureDependencySourceResolution(
return configureDependencySourceResolution(
new SourceResolverConfig( project, localRepository,
sourceDependencyCacheDir ).withReactorProjects( reactorProjects ) );
}
Expand Down Expand Up @@ -2656,7 +2683,7 @@ public Artifact resolveDependency( Dependency dependency )
coordinate.setVersion( dependency.getVersion() );
coordinate.setClassifier( dependency.getClassifier() );
coordinate.setExtension( artifactHandlerManager.getArtifactHandler( dependency.getType() ).getExtension() );

try
{
return artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), coordinate ).getArtifact();
Expand Down Expand Up @@ -3452,7 +3479,7 @@ private List<String> getArtifactsAbsolutePath( JavadocPathArtifact javadocArtifa
*
* @param javadocArtifact the {@link JavadocPathArtifact} to resolve
* @return a resolved {@link Artifact}
* @throws ArtifactResolverException
* @throws ArtifactResolverException
*/
private Artifact createAndResolveArtifact( JavadocPathArtifact javadocArtifact )
throws ArtifactResolverException
Expand Down Expand Up @@ -4718,6 +4745,8 @@ private void addStandardDocletOptions( File javadocOutputDirectory, List<String>

addArgIf( arguments, docfilessubdirs, "-docfilessubdirs", SINCE_JAVADOC_1_4 );

addArgIf( arguments, StringUtils.isNotEmpty( doclint ), "-Xdoclint:" + getDoclint(), SINCE_JAVADOC_1_8 );

addArgIfNotEmpty( arguments, "-doctitle", JavadocUtil.quotedArgument( getDoctitle() ), false, false );

if ( docfilessubdirs )
Expand Down

0 comments on commit 599355d

Please sign in to comment.