Martin Monperrus
Martin Monperrus

Reputation: 2051

How to disable Javadoc warnings in Maven Javadoc Plugin?

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?

Upvotes: 36

Views: 29234

Answers (7)

bish
bish

Reputation: 3419

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.

Upvotes: 0

Daniel C. Sobral
Daniel C. Sobral

Reputation: 297195

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.

Upvotes: 2

manikanta
manikanta

Reputation: 8500

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>

Upvotes: 8

Spring Monkey
Spring Monkey

Reputation: 5178

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

Upvotes: 20

Gray
Gray

Reputation: 116878

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>

Upvotes: 23

hzpz
hzpz

Reputation: 7911

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.

Upvotes: 30

Paul Back
Paul Back

Reputation: 1319

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

Upvotes: 14

Related Questions