How to disable Javadoc warnings in Maven Javadoc Plugin?
Asked Answered
A

7

35

I'm using the Maven Javadoc Plugin. It outputs warnings as follows:

[ERROR] /home/monperrus/spoon/src/main/java/spoon/visitor/CtVisitor.java:144:
      warning: no @param for <T>

How to not display those warnings?

Ardra answered 21/9, 2016 at 12:17 Comment(2)
Possible duplicate of Maven is not working in Java 8 when Javadoc tags are incompleteOysterman
Remember to accept an answer if it was helpful @Martin.Whang
O
29

Since version 3.0.0 of the maven-javadoc-plugin you can use the doclint configuration parameter. If you just want to disable the "missing" warnings, use all,-missing:

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

For more information see the doclint parameter documentation.

Ope answered 27/11, 2018 at 10:50 Comment(0)
W
23

How to display those warnings as [WARNING] (and not the confusing [ERROR])? How to completely disable Javadoc warnings in Maven?

If you are talking about the javadoc lint warnings introduced in Java 8 then you should be able to do the following. There are multiple ways of specifying the parameters depending on which version of the javadoc plugin you are using.

<plugins>
   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <configuration>
         <additionalparam>-Xdoclint:none</additionalparam>
         <additionalOptions>-Xdoclint:none</additionalOptions>
         <additionalJOption>-Xdoclint:none</additionalJOption>
      </configuration>
   </plugin>
</plugins>

See this good discussion about turning off doclint.

If you are instead just want to get rid of the missing jacadocs warnings then you can use:

<configuration>
   <additionalparam>-Xdoclint:all -Xdoclint:-missing</additionalparam>
   <additionalOptions>-Xdoclint:all -Xdoclint:-missing</additionalOptions>
   <additionalJOptions>
     <additionalJOption>-Xdoclint:all</additionalJOption>
     <additionalJOption>-Xdoclint:-missing</additionalJOption>
   </additionalJOptions>
</configuration>
Whang answered 15/3, 2017 at 22:43 Comment(0)
T
20

maven-javadoc-plugin version 2.9 onwards, setting additionalparam, doesn't seem to work. The new option that needs to be set is additionalJOption (see documentation). An example here:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
            <additionalJOption>-Xdoclint:none</additionalJOption>
        </configuration>
   </plugin>

Note that the warning are still displayed in the console, but not with the confusing "[ERROR]" prefix.

Note also, per the code of maven-javadoc-plugin that if there is at least one Javadoc error, all log lines will be prefixed by [ERROR].

Topo answered 29/1, 2018 at 23:57 Comment(0)
T
13

You can also disable it from the command line, in case you just want to locally suppress but not codify.

mvn clean install -Dadditionalparam=-Xdoclint:none

as Spring Monkey points out, in newer versions you may have to pass it in as

mvn clean install -DadditionalJOption=-Xdoclint:none
Tocantins answered 23/2, 2018 at 18:25 Comment(2)
Passing -DadditionalJOption=-Xdoclint:none option to mvn worked for me.Chud
You can also add -Ddoclint=none to the mvn command line maven.apache.org/plugins/maven-javadoc-plugin/…Passional
M
8

From v3.0.0, new doclint config option is added to configure the doc linting. This can be used to suppress these warnings.

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.1.1</version>
    <configuration>
      <doclint>none</doclint>  <!-- Turnoff all checks -->
    </configuration>
    <executions>
      <execution>
        <id>attach-javadocs</id>
        <goals>
          <goal>jar</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

For < v3.0.0, use as mentioned in previous answers

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
      <additionalparam>-Xdoclint:none</additionalparam>  <!-- Turnoff all checks -->
    </configuration>
    <!-- executions.... -->
  </plugin>
</plugins>
Melchior answered 9/8, 2019 at 12:29 Comment(0)
N
2

Compiling all the answers, and adding something else, we have the following.

To configure the maven project you should add this to the pom file:

<plugins>
   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <configuration>
         <additionalJOption>-Xdoclint:none</additionalJOption>
      </configuration>
   </plugin>
</plugins>

For Maven 2.9+ you need additionalJOption, and before that you need additionalparam. You can have additionalparam on Maven 2.9+ as it won't cause errors, but it won't make it work. I have not tested having additionalJOption on earlier versions of maven.

To configure it from the command line, you should pass this parameter:

mvn <goals> -Dadditionalparam=-Xdoclint:none -DadditionalJOption=-Xdoclint:none

To configure it on your shell environment, so that it will apply every time to every project without you needing to do anything else, add this line to your shell initialization (~/.bashrc or on Macs ~/.bash_profile, or whatever else your shell uses):

export JAVA_TOOL_OPTIONS="-Dadditionalparam=-Xdoclint:none -DadditionalJOption=-Xdoclint:none"

Or, if you have a JAVA_TOOL_OPTIONS, append those parameters to it.

Naca answered 9/7, 2018 at 17:41 Comment(0)
A
1

The maven plugin page shows how you can disable them_

<failOnWarnings>
<failOnError>

The default for warnings is false, so it won't break the build. The default for errors is (of course) true.

Astaire answered 30/12, 2023 at 20:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.