From 12a08bf36cb9b5734e3bd647af6f735a948eaf9e Mon Sep 17 00:00:00 2001
From: Elliotte Rusty Harold
- * See Where Tags
+ * See Where Tags
* Can Be Used.
*
* @author Vincent Siveton
@@ -771,10 +769,8 @@ private void parseClirrTextOutputFile( File clirrTextOutputFile )
clirrNewClasses = new LinkedList<>();
clirrNewMethods = new LinkedHashMap<>();
- BufferedReader reader = null;
- try
+ try ( BufferedReader reader = new BufferedReader( ReaderFactory.newReader( clirrTextOutputFile, "UTF-8" ) ) )
{
- reader = new BufferedReader( ReaderFactory.newReader( clirrTextOutputFile, "UTF-8" ) );
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
{
@@ -849,13 +845,6 @@ private void parseClirrTextOutputFile( File clirrTextOutputFile )
}
// CHECKSTYLE_ON: MagicNumber
}
-
- reader.close();
- reader = null;
- }
- finally
- {
- IOUtils.closeQuietly( reader );
}
if ( clirrNewClasses.isEmpty() && clirrNewMethods.isEmpty() )
{
@@ -1025,11 +1014,9 @@ private void processFix( JavaClass javaClass )
}
final StringWriter stringWriter = new StringWriter();
- BufferedReader reader = null;
boolean changeDetected = false;
- try
+ try ( BufferedReader reader = new BufferedReader( new StringReader( originalContent ) ) )
{
- reader = new BufferedReader( new StringReader( originalContent ) );
int lineNumber = 0;
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
@@ -1106,13 +1093,6 @@ else if ( lineNumber == javaClass.getLineNumber() )
stringWriter.write( line );
stringWriter.write( EOL );
}
-
- reader.close();
- reader = null;
- }
- finally
- {
- IOUtil.close( reader );
}
if ( changeDetected )
@@ -3068,19 +3048,18 @@ private static String getFullClirrGoal()
sb.append( CLIRR_MAVEN_PLUGIN_GROUPID ).append( ":" ).append( CLIRR_MAVEN_PLUGIN_ARTIFACTID ).append( ":" );
String clirrVersion = CLIRR_MAVEN_PLUGIN_VERSION;
- InputStream resourceAsStream = null;
- try
+
+ String resource = "META-INF/maven/" + CLIRR_MAVEN_PLUGIN_GROUPID + "/" + CLIRR_MAVEN_PLUGIN_ARTIFACTID
+ + "/pom.properties";
+
+ try ( InputStream resourceAsStream =
+ AbstractFixJavadocMojo.class.getClassLoader().getResourceAsStream( resource ) )
{
- String resource = "META-INF/maven/" + CLIRR_MAVEN_PLUGIN_GROUPID + "/" + CLIRR_MAVEN_PLUGIN_ARTIFACTID
- + "/pom.properties";
- resourceAsStream = AbstractFixJavadocMojo.class.getClassLoader().getResourceAsStream( resource );
if ( resourceAsStream != null )
{
Properties properties = new Properties();
properties.load( resourceAsStream );
- resourceAsStream.close();
- resourceAsStream = null;
if ( StringUtils.isNotEmpty( properties.getProperty( "version" ) ) )
{
clirrVersion = properties.getProperty( "version" );
@@ -3091,10 +3070,6 @@ private static String getFullClirrGoal()
{
// nop
}
- finally
- {
- IOUtil.close( resourceAsStream );
- }
sb.append( clirrVersion ).append( ":" ).append( CLIRR_MAVEN_PLUGIN_GOAL );
@@ -3137,7 +3112,7 @@ private static String getDefaultClassJavadocComment( final JavaClass javaClass )
* Default comment for method with taking care of getter/setter in the javaMethod name.
*
* @param javaExecutable not null
- * @return a default comment for method.
+ * @return a default comment for method
*/
private static String getDefaultMethodJavadocComment( final JavaExecutable javaExecutable )
{
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 a5bec36ae..d376dc2b1 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -145,7 +145,7 @@
*
* @author Brett Porter
* @author Vincent Siveton
- * @see
+ * @see
* The Java API Documentation Generator, 7
* @since 2.0
*/
@@ -220,7 +220,7 @@ public abstract class AbstractJavadocMojo
/**
* For Javadoc options appears since Java 1.4.
- * See
+ * See
* What's New in Javadoc 1.4
*
* @since 2.1
@@ -230,7 +230,7 @@ public abstract class AbstractJavadocMojo
/**
* For Javadoc options appears since Java 1.4.2.
* See
+ * href="https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.4.2.html#commandlineoptions">
* What's New in Javadoc 1.4.2
*
* @since 2.1
@@ -240,7 +240,7 @@ public abstract class AbstractJavadocMojo
/**
* For Javadoc options appears since Java 5.0.
* See
+ * href="https://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.5.0.html#commandlineoptions">
* What's New in Javadoc 5.0
*
* @since 2.1
@@ -249,7 +249,7 @@ public abstract class AbstractJavadocMojo
/**
* For Javadoc options appears since Java 6.0.
- * See
+ * See
* Javadoc Technology
*
* @since 2.4
@@ -258,7 +258,7 @@ public abstract class AbstractJavadocMojo
/**
* For Javadoc options appears since Java 8.0.
- * See
+ * See
* Javadoc Technology
*
* @since 3.0.0
@@ -370,11 +370,11 @@ public abstract class AbstractJavadocMojo
*
* <additionalJOption>-J-Xss128m</additionalJOption>
*
- * See Jflag.
+ * See Jflag.
*
* See vmoptions.
*
- * See Networking
+ * See Networking
* Properties.
*
* @since 2.3
@@ -489,7 +489,7 @@ public abstract class AbstractJavadocMojo
/**
* Specifies to use the
- *
+ *
* options provided by the Standard Doclet for a custom doclet.
*
* Example:
@@ -549,7 +549,7 @@ public abstract class AbstractJavadocMojo
private boolean detectOfflineLinks;
/**
- * Detect the Java API link for the current build, i.e. http://docs.oracle.com/javase/1.4.2/docs/api/
+ * Detect the Java API link for the current build, i.e. https://docs.oracle.com/javase/1.4.2/docs/api/
* for Java source 1.4.
*
* By default, the goal detects the Javadoc API link depending the value of the source
@@ -606,9 +606,8 @@ public abstract class AbstractJavadocMojo
* Specifies the paths where the boot classes reside. The bootclasspath
can contain multiple paths
* by separating them with a colon (:
) or a semi-colon (;
).
*
- * See bootclasspath.
- *
+ * See bootclasspath.
*
* @since 2.5
*/
@@ -618,8 +617,8 @@ public abstract class AbstractJavadocMojo
/**
* Specifies the artifacts where the boot classes reside.
*
- * See bootclasspath.
+ * See bootclasspath.
*
* Example:
*
@@ -643,10 +642,10 @@ public abstract class AbstractJavadocMojo
/**
* Uses the sentence break iterator to determine the end of the first sentence.
*
- * See breakiterator.
+ * See breakiterator.
*
- * Since Java
+ * Since Java
* 1.4.
*
*/
@@ -656,7 +655,7 @@ public abstract class AbstractJavadocMojo
/**
* Specifies the class file that starts the doclet used in generating the documentation.
*
- * See doclet.
+ * See doclet.
*/
@Parameter( property = "doclet" )
private String doclet;
@@ -666,7 +665,7 @@ public abstract class AbstractJavadocMojo
* option).
*
* See
- * docletpath.
+ * docletpath.
*
* Example:
*
@@ -688,7 +687,7 @@ public abstract class AbstractJavadocMojo
*
-doclet
option).
*
* See
- * docletpath.
+ * docletpath.
*
* Example:
*
@@ -715,7 +714,7 @@ public abstract class AbstractJavadocMojo
* a colon (
* :
) or a semi-colon (;
).
*
* See
- * docletpath.
+ * docletpath.
*/
@Parameter( property = "docletPath" )
private String docletPath;
@@ -724,7 +723,7 @@ public abstract class AbstractJavadocMojo
* Specifies the encoding name of the source files. If not specificed, the encoding value will be the value of the
* file.encoding
system property.
*
- * See encoding.
+ * See encoding.
*
* Note: In 2.4, the default value was locked to ISO-8859-1
to ensure reproducing build, but
* this was reverted in 2.5.
@@ -750,9 +749,9 @@ public abstract class AbstractJavadocMojo
* <excludePackageNames>*.internal:org.acme.exclude1.*:org.acme.exclude2</excludePackageNames>
*
- * See exclude.
+ * See exclude.
*
- * Since Java
+ * Since Java
* 1.4.
*
extdirs
with a
* colon (:
) or a semi-colon (;
).
* :
) or a semi-colon (;
).
* :
).
* <![CDATA[Copyright 2005, <a href="http://www.mycompany.com">MyCompany, Inc.<a>]]>
+ * If you want to use html, you have to put it in a CDATA section, <![CDATA[Copyright 2005, <a href="http://www.mycompany.com">MyCompany, Inc.<a>]]>
* docencoding
parameter.
* UTF-8
.
* javadocDirectory
directory (for instance,
* src/main/javadoc/com/mycompany/myapp/doc-files
and src/main/javadoc/resources
).
* :
).
* java.lang.*
for packages
would omit the java.lang
* package but using java.lang*
will include it.
* path/to/your/resource/yourhelp-doc.html
is defined in the
* groupId:artifactId:version
javadoc plugin dependency.
* /package-list
file. For instance:
* * <links> - * <link>http://docs.oracle.com/javase/1.4.2/docs/api</link> + * <link>https://docs.oracle.com/javase/1.4.2/docs/api</link> * <links> *- * will be used because
http://docs.oracle.com/javase/1.4.2/docs/api/package-list
exists.https://docs.oracle.com/javase/1.4.2/docs/api/package-list
exists.
* * <offlineLinks> * <offlineLink> - * <url>http://docs.oracle.com/javase/1.5.0/docs/api/</url> + * <url>https://docs.oracle.com/javase/1.5.0/docs/api/</url> * <location>../javadoc/jdk-5.0/</location> * </offlineLink> * </offlineLinks> @@ -1315,7 +1314,7 @@ public abstract class AbstractJavadocMojo /** * Specifies the destination directory where javadoc saves the generated HTML files. *
- * @see javadoc d + * @see javadoc d */ @Parameter( property = "destDir", alias = "destDir", defaultValue = "${project.build.directory}/apidocs", required = true ) @@ -1325,7 +1324,7 @@ public abstract class AbstractJavadocMojo * Specify the text for upper left frame. *
* Since - * + * * Java 1.4.2. * * @since 2.1 @@ -1336,7 +1335,7 @@ public abstract class AbstractJavadocMojo /** * Generates compile-time warnings for missing serial tags. *
- * @see serialwarn option + * @see serialwarn option */ @Parameter( property = "serialwarn", defaultValue = "false" ) private boolean serialwarn; @@ -1349,7 +1348,7 @@ public abstract class AbstractJavadocMojo * 4788919). *
* Since - * + * * 1.4.2. *
* Since Java 5.0. @@ -1366,7 +1365,7 @@ public abstract class AbstractJavadocMojo * Note: could be in conflict with <noindex/>. *
* See - * splitindex. + * splitindex. *
*/ @Parameter( property = "splitindex", defaultValue = "false" ) @@ -1419,7 +1418,7 @@ public abstract class AbstractJavadocMojo * Wherepath/to/your/resource/yourstylesheet.css
is defined in the *groupId:artifactId:version
javadoc plugin dependency. *
- * See + * See * stylesheetfile. */ @Parameter( property = "stylesheetfile" ) @@ -1428,10 +1427,10 @@ public abstract class AbstractJavadocMojo /** * Specifies the class file that starts the taglet used in generating the documentation for that tag. *
- * See taglet. + * See taglet. *
* Since - * Java 1.4. + * Java 1.4. */ @Parameter( property = "taglet" ) private String taglet; @@ -1440,7 +1439,7 @@ public abstract class AbstractJavadocMojo * Specifies the Taglet artifact containing the taglet class files (.class). *
* See - * tagletpath. + * tagletpath. *
* Example: *@@ -1472,10 +1471,10 @@ public abstract class AbstractJavadocMojo * Specifies several Taglet artifacts containing the taglet class files (.class). These taglets class names will be * auto-detect and so no need to specify them. *
- * See taglet. + * See taglet. *
* See - * tagletpath. + * tagletpath. *
* Example: *@@ -1502,10 +1501,10 @@ public abstract class AbstractJavadocMojo * multiple paths by separating them with a colon (:
) or a semi-colon (;
). *
* See - * tagletpath. + * tagletpath. *
* Since - * Java 1.4. + * Java 1.4. */ @Parameter( property = "tagletpath" ) private String tagletpath; @@ -1513,10 +1512,10 @@ public abstract class AbstractJavadocMojo /** * Enables the Javadoc tool to interpret multiple taglets. *
- * See taglet. + * See taglet. *
* See - * tagletpath. + * tagletpath. *
* Example: *@@ -1544,10 +1543,10 @@ public abstract class AbstractJavadocMojo /** * Enables the Javadoc tool to interpret a simple, one-argument custom block tag tagname in doc comments. *
- * See tag. + * See tag. *
* Since - * Java 1.4. + * Java 1.4. *
* Example: *@@ -1591,7 +1590,7 @@ public abstract class AbstractJavadocMojo /** * Includes one "Use" page for each documented class and package. *
- * See use. + * See use. *
*/ @Parameter( property = "use", defaultValue = "true" ) @@ -1600,7 +1599,7 @@ public abstract class AbstractJavadocMojo /** * Includes the version text in the generated docs. *
- * See version. + * See version. *
*/ @Parameter( property = "version", defaultValue = "true" ) @@ -1610,7 +1609,7 @@ public abstract class AbstractJavadocMojo * Specifies the title to be placed in the HTML title tag. *
* See - * windowtitle. + * windowtitle. *
*/ @Parameter( property = "windowtitle", defaultValue = "${project.name} ${project.version} API" ) @@ -4113,7 +4112,7 @@ private void addArgIfNotEmpty( Listarguments, String key, String value, * @throws MavenReportException if any * @see #offlineLinks * @see #getModulesLinks() - * @see package-list spec + * @see package-list spec */ private void addLinkofflineArguments( List arguments, Set offlineLinksList ) throws MavenReportException @@ -4167,7 +4166,7 @@ private Set getLinkofflines() throws MavenReportException * @throws MavenReportException issue while generating report * @see #detectLinks * @see #getDependenciesLinks() - * @see package-list spec + * @see package-list spec */ private void addLinkArguments( List arguments ) throws MavenReportException @@ -4281,7 +4280,7 @@ private void copyDefaultStylesheet( File anOutputDirectory ) * * @param anOutputDirectory the output directory * @throws java.io.IOException if any - * @see Reference + * @see Reference * Guide, Copies new "doc-files" directory for holding images and examples * @see #docfilessubdirs */ @@ -4425,7 +4424,7 @@ private List getPackageNames( Map > sourcePaths { /* * Remove the miscellaneous files - * http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed + * https://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed */ if ( currentFile.contains( "doc-files" ) ) { @@ -4506,7 +4505,7 @@ private List getPackageNamesRespectingJavaModules( Map getFilesWithUnnamedPackages( Map > { /* * Remove the miscellaneous files - * http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed + * https://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed */ if ( currentFile.contains( "doc-files" ) ) { @@ -4618,7 +4617,7 @@ private List getModuleSourcePathFiles( Map > sou { /* * Remove the miscellaneous files - * http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed + * https://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/javadoc.html#unprocessed */ if ( currentFile.contains( "doc-files" ) ) { @@ -4640,7 +4639,7 @@ private List getModuleSourcePathFiles( Map > sou * @param arguments not null * @param javadocOutputDirectory not null * @throws MavenReportException if any - * @see + * @see * Reference Guide, Command line argument files * @see #OPTIONS_FILE_NAME */ @@ -4680,10 +4679,10 @@ private void addCommandLineOptions( Commandline cmd, List arguments, Fil * @param javadocOutputDirectory not null * @param files not null * @throws MavenReportException if any - * @see + * @see * Reference Guide, Command line argument files * - * @see + * @see * What s New in Javadoc 1.4 * * @see #isJavaDocVersionAtLeast(JavaVersion) @@ -4731,7 +4730,7 @@ private void addCommandLineArgFile( Commandline cmd, File javadocOutputDirectory * @param javadocOutputDirectory not null * @param packageNames not null * @throws MavenReportException if any - * @see + * @see * Reference Guide, Command line argument files * @see #PACKAGES_FILE_NAME */ @@ -4897,7 +4896,7 @@ private void validateStandardDocletOptions() * @param arguments not null * @param allSourcePaths not null * @throws MavenReportException if any - * @see http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadocoptions + * @see https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadocoptions */ private void addJavadocOptions( File javadocOutputDirectory, List arguments, @@ -5358,8 +5357,8 @@ private File findMainDescriptor( Collection roots ) throws MavenReportExce * @param javadocOutputDirectory not null * @param arguments not null * @throws MavenReportException if any - * @see - * http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#standard + * @see + * https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#standard */ private void addStandardDocletOptions( File javadocOutputDirectory, List arguments, @@ -6046,8 +6045,8 @@ private String getResource( File outputFile, String inputResourceName ) } /** - * @param classPath a not null String list of files where resource will be look up. - * @param resource a not null ressource to find in the class path. + * @param classPath a not null String list of files where resource will be looked up + * @param resource a not null resource to find in the class path * @return the resource from the given classpath or null if not found * @see ClassLoader#getResource(String) * @since 2.6 @@ -6059,7 +6058,7 @@ private URL getResource( final List classPath, final String resource ) { try { - urls.add( new File( filename ).toURL() ); + urls.add( new File( filename ).toURI().toURL() ); } catch ( MalformedURLException e ) { @@ -6067,9 +6066,22 @@ private URL getResource( final List classPath, final String resource ) } } - ClassLoader javadocClassLoader = new URLClassLoader( urls.toArray( new URL[urls.size()] ), null ); - - return javadocClassLoader.getResource( resource ); + URLClassLoader javadocClassLoader = new URLClassLoader( urls.toArray( new URL[urls.size()] ), null ); + try + { + return javadocClassLoader.getResource( resource ); + } + finally + { + try + { + javadocClassLoader.close(); + } + catch ( IOException ex ) + { + // ignore + } + } } /** @@ -6080,18 +6092,14 @@ private URL getResource( final List classPath, final String resource ) private String getFullJavadocGoal() { String javadocPluginVersion = null; - InputStream resourceAsStream = null; - try + String resource = "META-INF/maven/org.apache.maven.plugins/maven-javadoc-plugin/pom.properties"; + try ( InputStream resourceAsStream + = AbstractJavadocMojo.class.getClassLoader().getResourceAsStream( resource ) ) { - String resource = "META-INF/maven/org.apache.maven.plugins/maven-javadoc-plugin/pom.properties"; - resourceAsStream = AbstractJavadocMojo.class.getClassLoader().getResourceAsStream( resource ); - if ( resourceAsStream != null ) { Properties properties = new Properties(); properties.load( resourceAsStream ); - resourceAsStream.close(); - resourceAsStream = null; if ( StringUtils.isNotEmpty( properties.getProperty( "version" ) ) ) { javadocPluginVersion = properties.getProperty( "version" ); @@ -6102,10 +6110,6 @@ private String getFullJavadocGoal() { // nop } - finally - { - IOUtil.close( resourceAsStream ); - } StringBuilder sb = new StringBuilder(); @@ -6131,7 +6135,7 @@ private String getFullJavadocGoal() * Using Maven, a Javadoc link is given by ${project.url}/apidocs
. * * @return the detected Javadoc links using the Maven conventions for all modules defined in the current project - * or an empty list. + * or an empty list * @throws MavenReportException if any * @see #detectOfflineLinks * @see #reactorProjects @@ -6454,7 +6458,7 @@ private SetfollowLinks( Set links ) * @param detecting true
if the link is generated by *detectLinks
, orfalse
otherwise * @returntrue
if the link has a/package-list
,false
otherwise. - * @see + * @see * package-list spec * @since 2.6 */ @@ -6496,7 +6500,6 @@ protected boolean isValidJavadocLink( String link, boolean detecting ) } - IOException elementListIOException = null; try { if ( JavadocUtil.isValidElementList( elementListUri.toURL(), settings, validateLinks ) ) @@ -6506,7 +6509,6 @@ protected boolean isValidJavadocLink( String link, boolean detecting ) } catch ( IOException e ) { - elementListIOException = e; } if ( JavadocUtil.isValidPackageList( packageListUri.toURL(), settings, validateLinks ) ) diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java index eec7639fc..43c9d3384 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java @@ -707,7 +707,7 @@ protected static ListgetTagletClassNames( File jarFile ) throws IOException, ClassNotFoundException, NoClassDefFoundError { List classes = getClassNamesFromJar( jarFile ); - ClassLoader cl; + URLClassLoader cl; // Needed to find com.sun.tools.doclets.Taglet class File tools = new File( System.getProperty( "java.home" ), "../lib/tools.jar" ); @@ -742,7 +742,16 @@ protected static List getTagletClassNames( File jarFile ) tagletClasses.add( c.getName() ); } } - + + try + { + cl.close(); + } + catch ( IOException ex ) + { + // no big deal + } + return tagletClasses; }