How to specify Javadoc HTML version with Maven?

Viewed 1636

When setting up Maven to generate Javadoc, I got this warning:

javadoc: warning - You have not specified the version of HTML to use. The default is currently HTML 4.01, but this will change to HTML5 in a future release. To suppress this warning, please specify the version of HTML used in your documentation comments and to be generated by this doclet, using the -html4 or -html5 options.

How do I do this?

3 Answers

I did this by adding additionalOptions to the configuration section of the Javadoc plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
                <additionalOptions>-html5</additionalOptions>
            </configuration>
        </plugin>
    </plugins>
</build>

I did this by adding another additionalJOption in configuration

<additionalJOptions>
  <additionalJOption>-J-Dhttp.agent=maven-javadoc-plugin-${project.name}</additionalJOption>
  <additionalJOption>-html5</additionalJOption>
</additionalJOptions>

Best to put it into a profile because -html5 is not supported below 1.9:

  <profile>
        <id>javadoc-html5</id>
        <activation>
            <jdk>[1.9,)</jdk>
        </activation>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <additionalOptions>-html5</additionalOptions>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>
Related