Using the Maven javadoc plugin you can exclude certain packages - but I have lots of packages and only a handful of classes I want to produce Javadoc for.
Is there a way to include rather than exclude?
I would also like to do things on a class level rather than a package level as I have some classes in a package which need javadoc and some which don't.
skip Option. The Maven Javadoc plugin has provided a maven. javadoc. skip option to skip the Javadoc generation. Our Maven build won't generate Javadocs if we pass this option with the value true when we build our project: mvn clean install -Dmaven.javadoc.skip=true.
The Javadoc Plugin uses the Javadoc tool to generate javadocs for the specified project. For more information about the standard Javadoc tool, please refer to Reference Guide. The Javadoc Plugin gets the parameter values that will be used from the plugin configuration specified in the pom.
The “maven-javadoc” plugin uses “ JDK\bin\javadoc.exe ” command to generate javadocs, pack in jar file and deploy along with your project.
The magic incantation you need is -Xdoclint:none . This goes on the command line invoking Javadoc.
Since maven-javadoc-plugin version 2.9, you can do this in your configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
....
<sourceFileIncludes>
<include>Foo.java</include>
<include>Bar.java</include>
</sourceFileIncludes>
<sourcepath>${basedir}/src/main/java/path/to/foo-and-bar</sourcepath>
....
</configuration>
....
... which would build a Javadoc site only including the mentioned classes.
Using the maven-javadoc-plugin, you cannot specify specific java classess (though you can with the javadoc utility, see below). However, via the the sourcepath configuration option for the javadoc:javadoc goal, you can configure specific packages. An example of this follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
<configuration>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<docfilessubdirs>true</docfilessubdirs>
<links>
<link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
</links>
<show>protected</show>
<source>1.5</source>
<sourcepath>${basedir}/src/main/java/com/acme/foo</sourcepath>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
In this example, all classes under the com.acme.foo package (including subpackages) will have javadoc generated.
It should be noted that this Maven plugin is simply a wrapper around Sun's javadoc utility. As such, most of the documentation and configuration for javadoc holds true for this plugin. See Sun's documentation on the javadoc sourcepath parameter.
In an area where the maven-javadoc-plugin differs in functionality, Sun's documentation for the sourcepath parameter mentions that it is possible with the javadoc utility to generate javadoc for specific classes. This capability is not available with the maven-javadoc-plugin. An example of this is shown in Sun's documentation:
C:> cd C:\home\src\java\awt
C:> javadoc -d C:\home\html Button.java Canvas.java Graphics*.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With