Search code examples
javamaven-2javadocpackage

javadoc for package-info.java only


I have a situation where I'd like to execute javadoc in a project that has no classes. It only has package-info.java for one package. When executing javadoc, the following error is given:

An error has occurred in JavaDocs report generation:Exit code: 1 - javadoc: error - No public or protected classes found to document.

Is there any way to force it to process package-info.java only (aside from the obvious hacky solutions: creating a dummy class, scripting the copying of a package.html, etc.)?

I'm executing javadoc as part of a maven build, so the maven-javadoc-plugin is performing the actual javadoc command.


Solution

  • There isn't a way to get JavaDoc to run on an empty package. There is a really old bug (JDK-4492654) posted for this marked as "Closed, Will Not Fix".

    In that bug the workaround is pretty much the obvious hacky one you mention, create a default-scoped empty class. The class won't be included in the javadoc unless you force it to be with -package or -private.

    /** hack to generate package javadoc */
    class PlaceHolder {}