diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java index fb18bf5c..ff065c7e 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java @@ -38,7 +38,6 @@ import com.thoughtworks.qdox.parser.ParseException; import com.thoughtworks.qdox.type.TypeResolver; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ClassUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; @@ -55,7 +54,6 @@ import org.codehaus.plexus.components.interactivity.InputHandler; import org.codehaus.plexus.languages.java.version.JavaVersion; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; @@ -91,7 +89,7 @@ /** * Abstract class to fix Javadoc documentation and tags in source files. *
- * 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 a5bec36a..d376dc2b 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. *

*/ @@ -763,7 +762,7 @@ public abstract class AbstractJavadocMojo * Specifies the directories where extension classes reside. Separate directories in extdirs with a * colon (:) or a semi-colon (;). *
- * See extdirs. + * See extdirs. */ @Parameter( property = "extdirs" ) private String extdirs; @@ -771,7 +770,7 @@ public abstract class AbstractJavadocMojo /** * Specifies the locale that javadoc uses when generating documentation. *
- * See locale. + * See locale. */ @Parameter( property = "locale" ) private String locale; @@ -800,7 +799,7 @@ public abstract class AbstractJavadocMojo * This option creates documentation with the appearance and functionality of documentation generated by * Javadoc 1.1. *
- * See 1.1. + * See 1.1. *
*/ @Parameter( property = "old", defaultValue = "false" ) @@ -812,7 +811,7 @@ public abstract class AbstractJavadocMojo *
* Note: could be in conflict with <nooverview/>. *
- * See overview. + * See overview. *
*/ @Parameter( property = "overview", defaultValue = "${basedir}/src/main/javadoc/overview.html" ) @@ -823,9 +822,9 @@ public abstract class AbstractJavadocMojo * easier to view. *
* Note: was a standard doclet in Java 1.4.2 (refer to bug ID - * 4714350). + * 4714350). *
- * See quiet. + * See quiet. *
* Since Java 5.0. *
@@ -837,13 +836,13 @@ public abstract class AbstractJavadocMojo * Specifies the access level for classes and members to show in the Javadocs. * Possible values are: * *
@@ -855,9 +854,9 @@ public abstract class AbstractJavadocMojo * Necessary to enable javadoc to handle assertions introduced in J2SE v 1.4 source code or generics introduced in * J2SE v5. *
- * See source. + * See source. *
- * Since Java + * Since Java * 1.4. */ @Parameter( property = "source" ) @@ -877,7 +876,7 @@ public abstract class AbstractJavadocMojo * multiple paths by separating them with a colon (:) or a semi-colon (;). *
* See - * sourcepath. + * sourcepath. */ @Parameter( property = "sourcepath" ) private String sourcepath; @@ -887,9 +886,9 @@ public abstract class AbstractJavadocMojo * colons (:). *
* See - * subpackages. + * subpackages. *
- * Since Java + * Since Java * 1.4. */ @Parameter( property = "subpackages" ) @@ -898,7 +897,7 @@ public abstract class AbstractJavadocMojo /** * Provides more detailed messages while javadoc is running. *
- * See verbose. + * See verbose. *
*/ @Parameter( property = "verbose", defaultValue = "false" ) @@ -911,7 +910,7 @@ public abstract class AbstractJavadocMojo /** * Specifies whether or not the author text is included in the generated Javadocs. *
- * See author. + * See author. *
*/ @Parameter( property = "author", defaultValue = "true" ) @@ -919,10 +918,10 @@ public abstract class AbstractJavadocMojo /** * Specifies the text to be placed at the bottom of each output file.
- * If you want to use html you have to put it in a CDATA section,
- * eg. <![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,
+ * e.g. <![CDATA[Copyright 2005, <a href="http://www.mycompany.com">MyCompany, Inc.<a>]]> *
- * See bottom. + * See bottom. *
*/ @Parameter( property = "bottom", @@ -934,7 +933,7 @@ public abstract class AbstractJavadocMojo * Specifies the HTML character set for this document. If not specificed, the charset value will be the value of * the docencoding parameter. *
- * See charset. + * See charset. *
*/ @Parameter( property = "charset" ) @@ -945,7 +944,7 @@ public abstract class AbstractJavadocMojo * UTF-8. *
* See - * docencoding. + * docencoding. */ @Parameter( property = "docencoding", defaultValue = "${project.reporting.outputEncoding}" ) private String docencoding; @@ -955,10 +954,10 @@ public abstract class AbstractJavadocMojo * directory from the javadocDirectory directory (for instance, * src/main/javadoc/com/mycompany/myapp/doc-files and src/main/javadoc/resources). *
- * See + * See * docfilessubdirs. *
- * Since Java + * Since Java * 1.4. *
* See javadocDirectory. @@ -973,7 +972,7 @@ public abstract class AbstractJavadocMojo /** * Specifies specific checks to be performed on Javadoc comments. *
- * See doclint. + * See doclint. * * @since 3.0.0 */ @@ -983,7 +982,7 @@ public abstract class AbstractJavadocMojo /** * Specifies the title to be placed near the top of the overview summary file. *
- * See doctitle. + * See doctitle. *
*/ @Parameter( property = "doctitle", defaultValue = "${project.name} ${project.version} API" ) @@ -993,10 +992,10 @@ public abstract class AbstractJavadocMojo * Excludes any "doc-files" subdirectories with the given names. Multiple patterns can be excluded * by separating them with colons (:). *
- * See + * See * excludedocfilessubdir. *
- * Since Java + * Since Java * 1.4. * * @see #docfilessubdirs @@ -1007,7 +1006,7 @@ public abstract class AbstractJavadocMojo /** * Specifies the footer text to be placed at the bottom of each output file. *
- * See footer. + * See footer. */ @Parameter( property = "footer" ) private String footer; @@ -1039,7 +1038,7 @@ public abstract class AbstractJavadocMojo * Note: using java.lang.* for packages would omit the java.lang * package but using java.lang* will include it. *
- * See group. + * See group. *
* See Javadoc. *
@@ -1050,7 +1049,7 @@ public abstract class AbstractJavadocMojo /** * Specifies the header text to be placed at the top of each output file. *
- * See header. + * See header. */ @Parameter( property = "header" ) private String header; @@ -1095,7 +1094,7 @@ public abstract class AbstractJavadocMojo * Where path/to/your/resource/yourhelp-doc.html is defined in the * groupId:artifactId:version javadoc plugin dependency. *
- * See helpfile. + * See helpfile. */ @Parameter( property = "helpfile" ) private String helpfile; @@ -1103,14 +1102,14 @@ public abstract class AbstractJavadocMojo /** * Adds HTML meta keyword tags to the generated file for each class. *
- * See keywords. + * See keywords. *
* Since - * + * * Java 1.4.2. *
* Since - * + * * Java 5.0. *
* @@ -1128,16 +1127,16 @@ public abstract class AbstractJavadocMojo *
  • all given links should have a fetchable /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.
  • + * will be used because https://docs.oracle.com/javase/1.4.2/docs/api/package-list exists. *
  • if {@link #detectLinks} is defined, the links between the project dependencies are * automatically added.
  • *
  • if {@link #detectJavaApiLink} is defined, a Java API link, based on the Java version of the * project's sources, will be added automatically.
  • * - * See link. + * See link. * * @see #detectLinks * @see #detectJavaApiLink @@ -1150,9 +1149,9 @@ public abstract class AbstractJavadocMojo * HTML documentation. *
    * See - * linksource. + * linksource. *
    - * Since Java + * Since Java * 1.4. *
    */ @@ -1162,9 +1161,9 @@ public abstract class AbstractJavadocMojo /** * Suppress the entire comment body, including the main description and all tags, generating only declarations. *
    - * See nocomment. + * See nocomment. *
    - * Since Java + * Since Java * 1.4. *
    */ @@ -1176,7 +1175,7 @@ public abstract class AbstractJavadocMojo *
    * See * nodeprecated. + * href="https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#nodeprecated">nodeprecated. *
    */ @Parameter( property = "nodeprecated", defaultValue = "false" ) @@ -1186,7 +1185,7 @@ public abstract class AbstractJavadocMojo * Prevents the generation of the file containing the list of deprecated APIs (deprecated-list.html) and the * link in the navigation bar to that page. *
    - * See + * See * nodeprecatedlist. *
    */ @@ -1198,7 +1197,7 @@ public abstract class AbstractJavadocMojo *
    * Note: could be in conflict with <helpfile/>. *
    - * See nohelp. + * See nohelp. *
    */ @Parameter( property = "nohelp", defaultValue = "false" ) @@ -1209,7 +1208,7 @@ public abstract class AbstractJavadocMojo *
    * Note: could be in conflict with <splitindex/>. *
    - * See noindex. + * See noindex. *
    */ @Parameter( property = "noindex", defaultValue = "false" ) @@ -1218,7 +1217,7 @@ public abstract class AbstractJavadocMojo /** * Omits the navigation bar from the generated docs. *
    - * See nonavbar. + * See nonavbar. *
    */ @Parameter( property = "nonavbar", defaultValue = "false" ) @@ -1246,9 +1245,9 @@ public abstract class AbstractJavadocMojo * <noqualifier>packagename1:packagename2</noqualifier> *
    * See - * noqualifier. + * noqualifier. *
    - * Since Java + * Since Java * 1.4. */ @Parameter( property = "noqualifier" ) @@ -1257,7 +1256,7 @@ public abstract class AbstractJavadocMojo /** * Omits from the generated docs the "Since" sections associated with the since tags. *
    - * See nosince. + * See nosince. *
    */ @Parameter( property = "nosince", defaultValue = "false" ) @@ -1267,10 +1266,10 @@ public abstract class AbstractJavadocMojo * Suppresses the timestamp, which is hidden in an HTML comment in the generated HTML near the top of each page. *
    * See - * notimestamp. + * notimestamp. *
    * Since - * + * * Java 5.0. *
    * @@ -1282,7 +1281,7 @@ public abstract class AbstractJavadocMojo /** * Omits the class/interface hierarchy pages from the generated docs. *
    - * @see notree option + * @see notree option */ @Parameter( property = "notree", defaultValue = "false" ) private boolean notree; @@ -1292,13 +1291,13 @@ public abstract class AbstractJavadocMojo * for external referenced classes. *
    * See - * linkoffline. + * linkoffline. *
    * Example: *
          * <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 * Where path/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( List arguments, 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 Set followLinks( Set links ) * @param detecting true if the link is generated by * detectLinks, or false otherwise * @return true 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 eec7639f..43c9d338 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 List getTagletClassNames( 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; }