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

java, javadoc, maven-2, maven-plugin

Solution

In the end I used the `sourcepath` configuration option to specify two packages containing the classes I wanted to Javadoc and gave classes in those packages that I didn't want to Javadoc default access. Setting the `show` configuration option to public allowed me to choose which classes Javadoc was produced for by setting there access to public. Full configuration below:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
        <links>
            <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
        </links>
        <source>1.5</source>
        <show>public</show>
        <doctitle>Foo API</doctitle>
        <title>Foo API</title>
        <bottom><![CDATA[Copyright notice]]></bottom>
        <sourcepath>${basedir}/src/main/java/com/foo/api;${basedir}/src/main/java/com/bar/api</sourcepath>
    </configuration>
</plugin>

However, this is essentially a workaround and I strongly agree with shek's comment that this should be an enchancement against the maven-javadoc-plugin as it is supported by the javadoc utility. http://jira.codehaus.org/browse/MJAVADOC

Problem

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.

Original source

Related problems