Maven javadoc plugin - how can I include only certain classes?

Supertux picture Supertux · Jul 28, 2009 · Viewed 19.3k times · Source

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.

Answer

RCross picture RCross · Nov 13, 2012

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.