diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 709a2dc9..a26d19cd 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -539,7 +539,7 @@ public abstract class AbstractJavadocMojo /** * Detect the links for all modules defined in the project. *
- * If {@link #reactorProjects} is defined in a non-aggregator way, it generates default offline links + * If {@code reactorProjects} is defined in a non-aggregator way, it generates default offline links * between modules based on the defined project's urls. For instance, if a parent project has two projects * module1 and module2, the -linkoffline will be: *
@@ -562,12 +562,7 @@ public abstract class AbstractJavadocMojo * By default, the goal detects the Javadoc API link depending the value of the source * parameter in the org.apache.maven.plugins:maven-compiler-plugin * (defined in ${project.build.plugins} or in ${project.build.pluginManagement}), - * or try to compute it from the {@link #javadocExecutable} version. - *
- * See - * Javadoc - * for the default values. - *
+ * or try to compute it from the {@code javadocExecutable} version. * * @see #links * @see #javaApiLinks @@ -1132,7 +1127,7 @@ public abstract class AbstractJavadocMojo *
* Notes: *
    - *
  1. only used if {@link #isOffline} is set to false.
  2. + *
  3. only used if {@code isOffline} is set to false.
  4. *
  5. all given links should have a fetchable /package-list file. For instance: *
          * <links>
    @@ -1140,35 +1135,31 @@ public abstract class AbstractJavadocMojo
          * <links>
          * 
    * will be used because https://docs.oracle.com/javase/1.4.2/docs/api/package-list exists.
  6. - *
  7. if {@link #detectLinks} is defined, the links between the project dependencies are + *
  8. if {@code detectLinks} is defined, the links between the project dependencies are * automatically added.
  9. - *
  10. if {@link #detectJavaApiLink} is defined, a Java API link, based on the Java version of the + *
  11. if {@code detectJavaApiLink} is defined, a Java API link, based on the Java version of the * project's sources, will be added automatically.
  12. *
* See link. - * - * @see #detectLinks - * @see #detectJavaApiLink - * @see #dependencyLinks */ @Parameter( property = "links" ) protected ArrayList links; - + /** - * Redefine the apidoc URL for specific dependencies when using {@link #detectLinks}. + * Redefine the apidoc URL for specific dependencies when using {@code detectLinks}. * Useful if the dependency wasn't build with Maven or when the apidocs have been moved. *
      * <dependencyLinks>
      *   <dependencyLink>
      *     <groupId>groupId</groupId>
      *     <artifactId>artifactId</artifactId>
-     *     <classifier>classifier</classifier> <!-- optional --> 
+     *     <classifier>classifier</classifier> <!-- optional -->
      *     <url>version</url>
      *   </dependencyLink>
      * </dependencyLinks>
      * 
- * + * * @see #detectLinks * @since 3.3.0 */ @@ -1334,7 +1325,7 @@ public abstract class AbstractJavadocMojo * </offlineLinks> * *
- * Note: if {@link #detectOfflineLinks} is defined, the offline links between the project modules are + * Note: if {@code detectOfflineLinks} is defined, the offline links between the project modules are * automatically added if the goal is calling in a non-aggregator way. *
* @see Javadoc. @@ -1454,9 +1445,9 @@ public abstract class AbstractJavadocMojo */ @Parameter( property = "stylesheetfile" ) private String stylesheetfile; - + /** - * Specifies the path of an additional HTML stylesheet file relative to the {@link #javadocDirectory} + * Specifies the path of an additional HTML stylesheet file relative to the {@code javadocDirectory} * Example: *
      *     <addStylesheets>
@@ -1467,7 +1458,7 @@ public abstract class AbstractJavadocMojo
      */
     @Parameter
     private String[] addStylesheets;
-    
+
     /**
      * Specifies the class file that starts the taglet used in generating the documentation for that tag.
      * 
@@ -1796,7 +1787,7 @@ public abstract class AbstractJavadocMojo * * } *
- * + * * note: requires at least Maven 3.3.1 * * @since 3.0.0 @@ -1893,7 +1884,7 @@ protected List getProjectBuildOutputDirs( MavenProject p ) /** * Either returns the attached artifact file or outputDirectory - * + * * @param project * @return */ @@ -1912,7 +1903,7 @@ protected File getClassesFile( MavenProject project ) return artifactFile; } } - else if ( project.getExecutionProject() != null + else if ( project.getExecutionProject() != null && project.getExecutionProject().getArtifact() != null && project.getExecutionProject().getArtifact().getFile() != null ) { @@ -1922,10 +1913,10 @@ else if ( project.getExecutionProject() != null return artifactFile; } } - + if ( project.getBuild().getOutputDirectory() != null ) { - return new File( project.getBuild().getOutputDirectory() ); + return new File( project.getBuild().getOutputDirectory() ); } else { @@ -2348,7 +2339,7 @@ protected Map> getFiles( Collection sourcePaths ) if ( StringUtils.isEmpty( subpackages ) ) { Collection excludedPackages = getExcludedPackages(); - + final boolean autoExclude; if ( release != null ) { @@ -2462,7 +2453,7 @@ protected Collection getSourcePaths() additionalSourcePaths.addAll( l ); } } - + if ( !additionalSourcePaths.isEmpty() ) { mappedSourcePaths.add( buildJavadocModule( subProject , additionalSourcePaths ) ); @@ -2487,7 +2478,7 @@ protected Collection getSourcePaths() getJavadocDirectory().getAbsolutePath() ) ); sourcePaths.addAll( l ); } - + if ( !sourcePaths.isEmpty() ) { mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), @@ -2499,7 +2490,7 @@ protected Collection getSourcePaths() return mappedSourcePaths; } - + private JavadocModule buildJavadocModule( MavenProject project, Collection sourcePaths ) { File classessFile = getClassesFile( project ); @@ -2507,14 +2498,14 @@ private JavadocModule buildJavadocModule( MavenProject project, Collection if ( resolvePathResult == null ) { return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ), - classessFile, + classessFile, sourcePaths ); } else { return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ), - classessFile, - sourcePaths, + classessFile, + sourcePaths, resolvePathResult.getModuleDescriptor(), resolvePathResult.getModuleNameSource() ); } @@ -2657,15 +2648,15 @@ private SourceResolverConfig getDependencySourceResolverConfig() andFilters.add( new PatternExclusionsFilter( dependencyExcludes ) ); } } - + return configureDependencySourceResolution( new SourceResolverConfig( project, getProjectBuildingRequest( project ), sourceDependencyCacheDir ) .withReactorProjects( this.reactorProjects ) ) .withFilter( new AndFilter( andFilters ) ); - + } - + private ProjectBuildingRequest getProjectBuildingRequest( MavenProject currentProject ) { return new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() ) @@ -3098,11 +3089,11 @@ private String getBottomText() /** * Method to get the stylesheet path file to be used by the Javadoc Tool. *
- * If the {@link #stylesheetfile} is empty, return the file as String definded by {@link #stylesheet} value. + * If the {@code stylesheetfile} is empty, return the file as String definded by {@code stylesheet} value. *
- * If the {@link #stylesheetfile} is defined, return the file as String. + * If the {@code stylesheetfile} is defined, return the file as String. *
- * Note: since 2.6, the {@link #stylesheetfile} could be a path from a resource in the project source + * Note: since 2.6, the {@code stylesheetfile} could be a path from a resource in the project source * directories (i.e. src/main/java, src/main/resources or src/main/javadoc) * or from a resource in the Javadoc plugin dependencies. * @@ -3131,18 +3122,18 @@ private Optional getStylesheetFile( final File javadocOutputDirectory ) return getResource( new File( javadocOutputDirectory, DEFAULT_CSS_NAME ), stylesheetfile ); } - + private void addAddStyleSheets( List arguments ) throws MavenReportException { if ( addStylesheets == null ) { return; } - + for ( String addStylesheet : addStylesheets ) { Optional styleSheet = getAddStylesheet( getJavadocDirectory(), addStylesheet ); - + if ( styleSheet.isPresent() ) { addArgIfNotEmpty( arguments, "--add-stylesheet", @@ -3151,8 +3142,8 @@ private void addAddStyleSheets( List arguments ) throws MavenReportExcep } } } - - + + private Optional getAddStylesheet( final File javadocOutputDirectory, final String stylesheet ) throws MavenReportException { @@ -3160,7 +3151,7 @@ private Optional getAddStylesheet( final File javadocOutputDirectory, fina { return Optional.empty(); } - + File addstylesheetfile = new File( getJavadocDirectory(), stylesheet ); if ( addstylesheetfile.exists() ) { @@ -3173,18 +3164,18 @@ private Optional getAddStylesheet( final File javadocOutputDirectory, fina + "than stylesheetfile: " + stylesheetfile.get().getName() ); } } - + return Optional.of( addstylesheetfile ); } - throw new MavenReportException( "additional stylesheet file does not exist: " + throw new MavenReportException( "additional stylesheet file does not exist: " + addstylesheetfile.getAbsolutePath() ); } /** * Method to get the help file to be used by the Javadoc Tool. *
- * Since 2.6, the {@link #helpfile} could be a path from a resource in the project source + * Since 2.6, the {@code helpfile} could be a path from a resource in the project source * directories (i.e. src/main/java, src/main/resources or src/main/javadoc) * or from a resource in the Javadoc plugin dependencies. * @@ -4324,10 +4315,10 @@ private void addArgIfNotEmpty( List arguments, String key, String value, } /** - * Convenience method to process {@link #offlineLinks} values as individual -linkoffline + * Convenience method to process {@code offlineLinks} values as individual -linkoffline * javadoc options. *
- * If {@link #detectOfflineLinks}, try to add javadoc apidocs according Maven conventions for all modules given + * If {@code detectOfflineLinks}, try to add javadoc apidocs according Maven conventions for all modules given * in the project. * * @param arguments a list of arguments, not null @@ -4373,7 +4364,7 @@ private Set getLinkofflines() throws MavenReportException /** * Convenience method to process {@link #links} values as individual -link javadoc options. - * If {@link #detectLinks}, try to add javadoc apidocs according Maven conventions for all dependencies given + * If {@code detectLinks}, try to add javadoc apidocs according Maven conventions for all dependencies given * in the project. *
* According the Javadoc documentation, all defined link should have ${link}/package-list fetchable. @@ -4469,9 +4460,9 @@ private void copyAllResources( File javadocOutputDirectory ) } /** - * Copies the {@link #DEFAULT_CSS_NAME} css file from the current class - * loader to the outputDirectory only if {@link #stylesheetfile} is empty and - * {@link #stylesheet} is equals to maven. + * Copies the {@code DEFAULT_CSS_NAME} css file from the current class + * loader to the outputDirectory only if {@code stylesheetfile} is empty and + * {@code stylesheet} is equals to maven. * * @param anOutputDirectory the output directory * @throws java.io.IOException if any @@ -5168,7 +5159,7 @@ private void addJavadocOptions( File javadocOutputDirectory, Map allModuleDescriptors = new HashMap<>(); boolean supportModulePath = javadocRuntimeVersion.isAtLeast( "9" ); - if ( release != null ) + if ( release != null ) { supportModulePath &= JavaVersion.parse( release ).isAtLeast( "9" ); } @@ -5682,14 +5673,14 @@ private void addStandardDocletOptions( File javadocOutputDirectory, addArgIf( arguments, splitindex, "-splitindex" ); Optional stylesheetfile = getStylesheetFile( javadocOutputDirectory ); - + if ( stylesheetfile.isPresent() ) { addArgIfNotEmpty( arguments, "-stylesheetfile", JavadocUtil.quotedPathArgument( stylesheetfile.get().getAbsolutePath() ) ); } - - addAddStyleSheets( arguments ); + + addAddStyleSheets( arguments ); if ( StringUtils.isNotEmpty( sourcepath ) && !isJavaDocVersionAtLeast( SINCE_JAVADOC_1_5 ) ) { @@ -6348,7 +6339,7 @@ private String getFullJavadocGoal() { String javadocPluginVersion = null; String resource = "META-INF/maven/org.apache.maven.plugins/maven-javadoc-plugin/pom.properties"; - try ( InputStream resourceAsStream + try ( InputStream resourceAsStream = AbstractJavadocMojo.class.getClassLoader().getResourceAsStream( resource ) ) { if ( resourceAsStream != null ) @@ -6497,7 +6488,7 @@ private List getModulesLinks() * @return the detected Javadoc links using the Maven conventions for all dependencies defined in the current * project or an empty list. * @see #detectLinks - * @see #isValidJavadocLink + * @see #isValidJavadocLink(String, boolean) * @since 2.6 */ private List getDependenciesLinks() @@ -6521,7 +6512,7 @@ private List getDependenciesLinks() Optional depLink = this.dependencyLinks.stream().filter( d -> matches( d, artifact ) ).findAny(); - + final String url; final boolean detected; if ( depLink.isPresent() ) @@ -6545,7 +6536,7 @@ private List getDependenciesLinks() continue; } } - + if ( url != null && isValidJavadocLink( url, detected ) ) { getLog().debug( "Added Javadoc link: " + url + " for " + artifact.getId() ); @@ -6575,13 +6566,11 @@ private boolean matches( DependencyLink d, Artifact artifact ) } /** - * @return if {@link #detectJavaApiLink}, the Java API link based on the {@link #javaApiLinks} properties and the + * @return if {@code detectJavaApiLink}, the Java API link based on the {@code javaApiLinks} properties and the * value of the source parameter in the * org.apache.maven.plugins:maven-compiler-plugin * defined in ${project.build.plugins} or in ${project.build.pluginManagement}, - * or the {@link #javadocRuntimeVersion}, or null if not defined. - * @see #detectJavaApiLink - * @see #javaApiLinks + * or the {@code javadocRuntimeVersion}, or null if not defined. * @see source parameter * @since 2.6 */