27

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 display those warnings as [WARNING] (and not the confusing [ERROR])?

Gray
  • 108,756
  • 21
  • 270
  • 333
Martin Monperrus
  • 1,375
  • 1
  • 14
  • 23
  • 1
    Possible duplicate of [Maven is not working in Java 8 when Javadoc tags are incomplete](https://stackoverflow.com/questions/15886209/maven-is-not-working-in-java-8-when-javadoc-tags-are-incomplete) – BalusC Sep 17 '17 at 06:49
  • Remember to accept an answer if it was helpful @Martin. – Gray Feb 25 '19 at 16:48

6 Answers6

22

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>
Martin Monperrus
  • 1,375
  • 1
  • 14
  • 23
Gray
  • 108,756
  • 21
  • 270
  • 333
17

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].

Martin Monperrus
  • 1,375
  • 1
  • 14
  • 23
Spring Monkey
  • 4,570
  • 7
  • 30
  • 33
13

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.

hzpz
  • 6,563
  • 1
  • 33
  • 42
10

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
Paul Back
  • 1,041
  • 13
  • 20
  • Passing `-DadditionalJOption=-Xdoclint:none` option to `mvn` worked for me. – haridsv Jan 23 '19 at 09:24
  • 1
    You can also add `-Ddoclint=none` to the `mvn` command line https://maven.apache.org/plugins/maven-javadoc-plugin/aggregate-mojo.html#doclint – Thomas Taylor Nov 26 '19 at 18:08
3

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>
manikanta
  • 7,066
  • 5
  • 52
  • 61
1

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>
         <additionalparam>-Xdoclint:none</additionalparam>
         <additionalJOption>-Xdoclint:none</additionalOptions>
      </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.

Daniel C. Sobral
  • 284,820
  • 82
  • 479
  • 670