Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-javadoc-plugin not accepting <additionalparam>-Xdoclint:none</additionalparam>

A mvn release:perform is failing due to javadocs not being created. So I tried running

mvn javadoc:javadoc

myself and I see that it fails due to the javadoc comments in the source code not having definitions for all of the parameters and return values. Errors are of the format:

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.1:jar (attach-javadocs) on project my-project: MavenReportException: Error while generating Javadoc:

Exit code: 1 - /my/file.java:36: warning: no description for @return

This, however, used to work. So what changed?

I checked the maven-javadoc-plugin documentation and it now (in v3.0) says the parameter is not additionalParam, or additionalparam, but additionalOptions, and additionalJOptions. See maven-javadoc-plugin documentation.

When I searched for the parameter additionalParam, it does not appear. I'm confused how this could have worked. Searching for answers some people say to use what I'm using, others say to use additionalJOption. See Maven is not working in Java 8 when Javadoc tags are incomplete.

How can I fix it?

Any ideas on what caused the problem and how to fix it?

What I've tried

Luckily, I found a work around which was to disable the Javadoc linting from the command line:

mvn release:perform -Darugments="-Dmaven.javadoc.skip=true"

Kudo's to code.i-harness.com posting that gave me this work around.

So I'm passed the initial problem, but want/need to clean up the poms to remove useless parameters, or change them to the new/correct syntax (not yet tested).

Searches that were useful

Searching on SO gives these hits that were useful:

  • How can I disable the Maven Javadoc plugin from the command line? - Gave me the idea to search for maven.javadoc.skip which helped me find my work around.

  • Maven is not working in Java 8 when Javadoc tags are incomplete which says I should use additionalJOption parameter. The same question has an answer that says to use what I'm using <additionalparam>-Xdoclint:none</additionalparam>

like image 840
PatS Avatar asked Sep 28 '18 02:09

PatS


People also ask

How do I fix Javadoc errors?

You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).

What is Maven Javadoc plugin?

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.

Which will prevent Javadoc from being generated while using DocLint?

The magic incantation you need is -Xdoclint:none . This goes on the command line invoking Javadoc.

What is DocLint?

Java DocLint is a tool to analyze our Javadoc. It throws warnings and errors whenever it finds bad syntax. In this tutorial, we focus on how we can use it. Later, we'll look at the problems it can create in certain situations, along with some guidelines on how we can avoid them.


1 Answers

You should use the doclint option instead:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.0.1</version>
    <configuration>
        <doclint>none</doclint>
    </configuration>
</plugin>

This will skip all checks. Generally, I would recommend to run all checks except for missing @return and @param. So instead of none, you could use:

        <doclint>all,-missing</doclint>

Individual groups of checks can be switched on or off (like the -missing above). A detailed description of the groups can be found in the javadoc documentation (at the bottom of the page).

like image 145
gjoranv Avatar answered Nov 16 '22 02:11

gjoranv